C++ help?

Posts 1–15 of 37 · Page 1 of 3
C++ help?
So i just started C++ and i got a book called C++ A Begginers guide second edition and it said to type in

/*
This is a simple C++ program.

Call this file sample.cpp.
*/

#include <iostream>
using namespace std;

// A C++ program begins at main ()
int main ()
{
cout << "C++ is power programming.";

return 0;
}
In my compiler so i put it in microsoft visual c++ 2008 express but it never told me what kind of project it was supposed to be and just told me to copy it in. I made my project a win32 console application and typed it in exactly but it couldn't compile it. So i read ahead of the book and it said to first name it sample.cpp which i already did and it said to first type it in wordpad so i did that to. after i did that it showed me a lot of command lines.

Could you people help me? i just started so sorry for being such a nooby.

Oh and i have to go so sorry i can't stay on this page for to long right now so if i dont reply to your answers or suggestions on my mistakes please forgive me. thanks!
Mind posting the errors you were getting?
Quote Originally Posted by Void View Post
Mind posting the errors you were getting?
fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add 'c "stdafx.h"' to your source?

The book didn't mention anything about the #include stdafx.h so i dont think im supposed to put that in

I read on to what to do if i needed help and it said to use the command line C:\...>cl -GX Sample.cpp

Any idea what that is?
It should be a win32 app if your beginner (Thats what iam starting with)

I'll post pic

Then what do you mean it's not compiling? If it didn't compile there must be some error...
Quote Originally Posted by Void View Post
Then what do you mean it's not compiling? If it didn't compile there must be some error...
It just said it failed and in the book it said to add C:\...>cl -GX but i dont know what that is
The book is telling you to compile from Visual Studio's command line. CL.exe is the compiler it uses. -GX is like a parameter for CL. I recommend using a simpler IDE, such as Dev-C++..
Quote Originally Posted by Void View Post
The book is telling you to compile from Visual Studio's command line. CL.exe is the compiler it uses. -GX is like a parameter for CL. I recommend using a simpler IDE, such as Dev-C++..
ok ill try that out right now
Create a empty project
Right-Click on Source Files
Add New Item
Name it Sample.cpp
Add code
Profit

i honestly don't see what could go wrong
New project > Empty Project > Right click on the Folder "source" and create New .cpp file.
Quote Originally Posted by Kallisti View Post
New project > Empty Project > Right click on the Folder "source" and create New .cpp file.
Where is the folder source?
Quote Originally Posted by poip0i View Post
Where is the folder source?


Well I guess creating an empty project works too. =o=
well, thaats how i learned it, and because i dont like creating projects with main.cpp already created with some random code
I think you should just use Dev-C++ until you've gained some experience using a basic IDE. Or you can be a man and use the command line to compile.
Posts 1–15 of 37 · Page 1 of 3

Post a Reply

Similar Threads

Tags for this Thread

Talk with us