Please help a total newb

hi guys,

just picked up a book called c++ for absolute beginners by mark lee

like it so far...but im battling with some things.

his examples are written for ms visual c++ studio 2008 and im using 2010

when i copy and try to run i get errors...
why is this happening...is there a huge difference between 08 and 2010?

whats the best thing to do? get a book for 2010 or down grade to 08?
or can this be addressed?

below are the errors i get...

please help...im anctious to get started...

1>------ Build started: Project: hello world, Configuration: Debug Win32 ------
1> helloworld.cpp
1>c:\users\user\documents\visual studio 2010\projects\hello world\hello world\helloworld.cpp(2): warning C4067: unexpected tokens following preprocessor directive - expected a newline
1>c:\users\user\documents\visual studio 2010\projects\hello world\hello world\helloworld.cpp(2): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\user\documents\visual studio 2010\projects\hello world\hello world\helloworld.cpp(10): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


If you post your full helloworld.cpp source code we can easily fix this for you.
Could you please paste your code?
no prob guys...here it is:

//1.1 – Hello World – Mark Lee
#include <iostream>
int main( void )
{
using std::cout;
cout << "Hello World!\n";
return 0;
}

thanks for replying
In VS2008 I always had to press <ENTER> after the last brace or the compiler wouldn't recognize that line.

Moreover, you need to wipe out that project and start a new one, only this time make sure you create an EMPTY project.

The others here can maybe help you with other stuff.
closed account (zb0S216C)
warning C4067: unexpected tokens following preprocessor directive - expected a newline
Well, according to your warnings, it appears as though you have trailing characters at the end of a preprocessor directive.

warning C4627: '#include <iostream>': skipped when looking for precompiled header use
It appears as though Visual Studio/Express is expecting you to place include directives in Stdafx.h.

To get around the Stdafx.h header, you can disable it in your project options. Just look for Precompiled Headers under the C/C++ node.

Wazzak
Last edited on
is there a book i should use with visual c++ 2010 to learn c++ or is pretty normal to begin with...ie would i have problems regardless of book / compiler combination...ie it requires tweaking.

thanks for the response...you guys are great...

lastly....can you coders out there type really fast? i mean should i learn to touch type? i use 6 fingers and am not that slow...but wondered how much of an impact this would have
Dont' worry about the typing.

If you're going to program Windows, then this book is a must --

http://www.amazon.com/Programming-Windows%C2%AE-Fifth-Microsoft/dp/157231995X/ref=sr_1_3?ie=UTF8&qid=1307046012&sr=8-3

It's a bit dated, but it sill contains a goldmine of Windows programming information and tons of programs and code.

An outstanding book on C/C++ is this one --

http://www.amazon.com/Primer-Plus-5th-Stephen-Prata/dp/0672326973/ref=sr_1_1?ie=UTF8&s=books&qid=1307046099&sr=1-1

If you get a good handle on the info in these two books you willl be well on your way to writing nice programs.

Finally, here is a free online tutorial for basic Windows programming --

http://www.winprog.org/tutorial/

Note that this online tutorial is pretty basic. The first link I gave you goes a lot deeper, and is very much worth owning. I still refer to it from time to time.
Last edited on
Incidentally, in my opinion you are wasting your money by buying super basic books on programming. They give you very little bang for the buck.

If you really want to learn to program, buy books that go a bit deeper. You'll be glad you did.

The two books I gave you above might be considered introductory by experienced programmers, but they contain a lot more meat than "Such And Such A Book For Dummies", and so on.

If you work through Prata's book, the second link I gave you, you will have a very sound basic understanding of C/C++ programming.
Last edited on
Lamblion i cant thank you enough man!!! i have just ordered both books...do you recommend i read them intermitently or start the first one cover to cover,then the next?
cant wait...do the books come with a compiler or do i use visual c++ express 2010.

look, i dont want to kid myself either...i currently work in a computer shop...i am reading a book on DNS and MCITP as well as trying to get into slackware during the day. i can only dedicate a couple of hours at night to C++, do you think im wasting my time...

i dont want to go career, but i feel my computing lacks a sense of creativity i used to have when i used to program in basic on my c64, when i was like 14.

it would be nice to write a few things i could use. my wife is studying Action script / j querry so
i thought i would stay away from java to be different...i was also thinking about python...

thanks again
its cause of good people like you that i still have faith in this world...
TSN

I would work through the first portion of Prata's C++ Primer Plus before you get into Petzold's book. Once you covered eight or ten chapters in Prata's book you'll understand enough to work some things out in Petzold.

It just takes staying at it until things begin to come together.

And yes, most definitely use VS C++ Express. It is a great tool for beginners and has the most support, and also, of course, many pros, if not most pros, use VS 2010 as well.
One more thing. Petzold's book comes with a CD with all the programs on it. I don't remember if Prata's does or not.

Either way, I recommend that you type all the examples in yourself instead of pasting from the CD. You'll learn and retain a whole lot more that way.

Just be sure to gain a basic understanding of C/C++ from at least the first portion of Prata before you get into Petzold, for most everything in Petzold is based on at least a basic understanding of C/C++.
Last edited on
again thanks man...starting tonight...with a few tutorials
Last edited on
Topic archived. No new replies allowed.