Archived

This topic is now archived and is closed to further replies.

Newbie / Visual C++ error

This topic is 5112 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, I got the book Game Programming All in One by Bruno Miguel Teixeira de Sousa. I''m on the very first example and am already having trouble, I think the code is all input correctly but when I press ctrl+f5 to compile it I get the following errors. The Code is here ---> /* ''01main.cpp'' */ /* Input output stream header file */ #include <iostream> /* Start */ main (void) { std::cout << "Hello all you happy people" << std::endl; return 0; } The Errors are here ---> _____ These project configuration(s) are out of date: filename - Debug Win32 Would you like to build them? _____ Yes _____ There were build errors. Continue? _____ Yes ____ Unable to start debugging Unable to start program ''c:\AllinOne\filename\Debug\filename.exe'' The system cannot find the file specified ____ I''m hoping it''s something simple or something a little over my head at this point cos it''s sort of ridiculous to be stuck on the "Hello World" type of example. Thanks.

Share this post


Link to post
Share on other sites
Ok, if there were build errors, the executable was never created. So when you said continue --> yes after the compiler asked you, it could not find the app to start.

Select no when it asks if there are build errors and do you want to continue.

Also, the code for the most part looks ok except for your main declaration.

Try this:


int main(int argc, char* argv[])
{
std::cout << "Hello all you happy people" << std::endl;

return 0;
}


Alek

Share this post


Link to post
Share on other sites
you don''t have to include "int argc, char* argv[]", but be sure to use int main() or int main(void) would work despite its redundant parameter.

Share this post


Link to post
Share on other sites
Thanks for the replies but I''m still at the same spot.

My current code is --->

/* ''01main.cpp'' */

/* Input output stream header file */
#include <iostream>

/* Start */
int main()
{
std::cout << "Hello all you happy people" << std::endl;
return 0;
}



Error description --->

c:\AllInOne\Chapter01\01main.cpp(12): fatal error C1010: unexpected end of file while looking for precompiled header directive


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Try this.

#include<iostream>
using namespace std;

int main(void)
{
cout<<"Hello people";

return 0;
}

Share this post


Link to post
Share on other sites
disable precompiled headers:

(assuming vc++ 6)

project menu / settings / c++ tab / precompiled header category / select "not using precompiled headers".

should work then.

for precompiled header you have to use stdafx.h I think. Maybe someone who knows more about precompiled headers will explain more if you''re interested.

Share this post


Link to post
Share on other sites
To get rid of the build error message go to project->Settings->C++ tab->

Under category, select precompiled headers, and then select not using precomiled headers. Click ok, rebuild project.

[EDIT] Too slow. dough [/EDIT]

[edited by - pjcast on December 16, 2003 7:18:28 PM]

Share this post


Link to post
Share on other sites
nope, but thanks.

So my current code is -->

#include
using namespace std;

int main(void)
{
cout<<"Hello people";

return 0;
}


I get the same sequence of errors and my error description is -->
c:\AllInOne\Chapter01\01main.cpp(10): fatal error C1010: unexpected end of file while looking for precompiled header directive

Share this post


Link to post
Share on other sites
Noticed there were two more replies, I''ll give those a shot. Also, and sorry I didn''t mention. It''s Visual C++.Net, maybe that makes a difference.

Can anyone give me a clue as to what I''m dealing with here exactly?

Share this post


Link to post
Share on other sites
Ok, now I''m getting somewhere, I turned off precompiling headers by right clicking on my project in the solution explorer and going to properties > c++ > precompiled headers because there was nothing similar under the project menu.

Now, I''ve tried many of the versions of code above and when my program window pops up it''s blank/white whatever you''d want to call it.

Thanks for all the help so far by the way, it''s been great.

Share this post


Link to post
Share on other sites
quote:
Original post by nh
Now, I''ve tried many of the versions of code above and when my program window pops up it''s blank/white whatever you''d want to call it.


I don''t know how .NET operates, but I assume there''s somewhere that you choose the project type when creating it. You need to be making a WIN32 Console Application.

Tadd
- WarbleWare

Share this post


Link to post
Share on other sites
may have messed up the copy paste somehow, current code -->

#include
using namespace std;

int main(void)
{
cout<<"Hello people";

return 0;
}

same blank project???

Share this post


Link to post
Share on other sites
I believe that is what I chose but I will start from scratch and try again.

thanks.

Contrary to what I believed a few minutes ago, I was using a windows application instead of a console application, i also wasn't using an empty project which may have given me the problems with the precompiled headers.

Thanks a bunch, I know I've wasted your time but you've definitely helped me learn a few things.

[edited by - nh on December 16, 2003 8:06:44 PM]

Share this post


Link to post
Share on other sites
Dude, I had that same problem!! It''s preprocessor directives!!!! If you include this : "#include <stdafx.h>" without the quote, before all the code, then it should run FINE!

BattleGuard



Only questions raise questions. Questions are raised by people, by curiousity, the gift of nature to all human beings. And curiosity is satisfied by answers, which in turn raise questions, which lead to answers. And this curiosity is what keeps SCIENCE alive...

Share this post


Link to post
Share on other sites
quote:
Original post by BattleGuard
Dude, I had that same problem!! It''s preprocessor directives!!!! If you include this : "#include <stdafx.h>" without the quote, before all the code, then it should run FINE!

BattleGuard



The preprocessor has absolutely nothing to do with it, so I don''t know what you mean, but including stdafx.h is completely pointless unless you''re actually using precompiled headers, and they''re really almost entirely useless.

Share this post


Link to post
Share on other sites
Create a new proyect (menu file/new/proyect/win32 console proyect)

Clic in "aplication config" on the new dialog which has just pop.
Check "empty proyect" in "additional options"

That way you will create a proyect w/out precompiler headers, but if you don´t want to make a new proyect, just delete both stdafx.cpp and stdafx.h files from your proyect explorer. Then edit proyect properties (menu proyect/properties)
In the C++ folder look for precompiled headers; the first option is "create or use precompiled headers" switch it to "Do not create or use precompiler headers"

Finaly make sure you change
int _tmain(int argc, _TCHAR* argv[])
for
int main (int argc, char* argv[]) or int main()
and get rid of #include "stdafx.h"

Your proyect should compile just fine now.


Regards.

Sorry if any menu´s name is wrong, because english isn´t my native language, so I´m translating from my Visual C++ versión.

[edited by - zheo on December 17, 2003 12:35:49 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

This will work with visual c++.net

#include<iostream>
#include<string>
using namespace std;

int main(void)
{
string exit;

cout<<"Hello people!"<<endl;
cin>>exit;

return 0;
}

Share this post


Link to post
Share on other sites