Really REALLY newbie here...
Newbie here, with a newbie question. Please forgive me if it sounds stupid. I'm talking like "Never used Visual c++ 6.0 before today" stupidity here, because that's actually the case.
Okay, I'm just trying to make some simple program I have seen in this book I have here, and boom, I get this error message each time.
c:\program files\microsoft visual studio\myprojects\file\file.cpp(28) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe
Now then, the code I inserted is as follows.
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "print this" << endl;
void main()
}
Now then, I am not even sure how to go about starting a new project correctly. When I start up a new file using file-new, I choose the projects tab and select win32 application because that's the closest to what I think would work.
Okay, tell me exactly how badly I'm doing this. It's the only way I'll learn. Thanks for your help, and I apologize for how stupid this must seem.
# 1 Re: Really REALLY newbie here...
I'm not too sure about the statement 'void main()' but I'm pretty sure it should have a semicolon after it.
# 2 Re: Really REALLY newbie here...
Hello
U need to remove the statement "void main()" as jman_77 indicated, i m a little suspecious about this statement it has no meaning. So i'll say : "Just remove it from here", and wala! u got a compiling, executing, running program. and by the way u can use "getch()" function which will introduce a pause in ur program, but u need to include its header file "conio.h" and also u should "return" from ur "main", Like This:
#include <iostream>
#include <string>
#include<conio.h>
using namespace std;
int main()
{
cout << "print this" << endl;
getch();//wait untill i press a key
return 0;//end main
}
Hope this helps
Aamir!
# 3 Re: Really REALLY newbie here...
you want to choose new console application.
main is not a function you call like that, it is the entry point of your program. if it were a function you call in such a manner, jman_77 is right in that it would need a semicolon after it.
c++ doesn't care about "white space" in your program so you must let it know with a semi colon that it's hit the end of a command. the only exception to this is with boolean expressions and function definitions. also you wouldn't put the int in front of the function call. you could type cast the return value in a similiar manner but by saying int myFunc(); you will get some compiler error (does not evaluate to a function, illegal use of type 'blah' or local function definitions are illegal) that's just a heads up for future stuff.
ok so that's what you should know for the future. aamirnadil's post is what you should do for now. good luck.
# 4 Re: Really REALLY newbie here...
I put in aamirnadil's code and ran it (after selecting win32 console application to start).
I got an error message telling me that the exe file for this application (named what I named the project) was not found. It asked me to create it. I said yes. Then, it failed with the same failure as before. I tried again, thinking well now it's made. Same problem. I tried using the save command, saving as, and save all. Same problem. I then tried using the build drop down menu to tell it to build the exe file. Every single time it tries to do this, it always gives me the same error. The debug screen always says it had an error executing cl.exe.
Can someone please help me solve this? I do believe the problem may actually be with Visual C++ 6.0 itself now, or at least how I'm using it, as opposed to the code.
# 5 Re: Really REALLY newbie here...
go to project\settings... on the "settings for" menu on the left click "all configurations"... then click the C/C++ tab, in category click Precompiled Headers, then click "not using precompiled headers" then click ok and you can delete the files stdafx.cpp and stdafx.h from your project... er.. that should work... i dunno
# 6 Re: Really REALLY newbie here...
I'm afraid that didn't work... Anyway, can someone with experience on this kind of error help me?
# 7 Re: Really REALLY newbie here...
zipping up your project and post it here as an attachment would be the easy way for someone to tell what's going on.
Mick at 2007-11-10 9:00:14 >

# 8 Re: Really REALLY newbie here...
You've got a couple of things going on, most of these have been pointed out, but let's just review:
1. syntax errors (calling main() from main())
2. the project appears to be set up for mfc, and wants stdafx.h included (the error you're getting, and the advice about precomplied errors.)
The first is easily fixed, you've proably already done so... the 2nd is possible but you need to ensure that all of the setting are right and the appropiate lib's are included, etc...
The best bet is to start a new project using the app wizard, (File/new), select the Project tab, click the create new work space radio, find & select the Win32 console application, give it a name and a directory. Press ok. You should be presented with options to create an empty, simple, hello world, or MFC enabled application. Choose "Hello World", press ok and generate the project. Now, you can copy your code into the .cpp file that the project contains (just copy and insert the includes, and replace the existing code in main with your code from main, and leave stdafx.h). You can also have two VS's running one with your old project and the new one and you can examine the differences...
bytz at 2007-11-10 9:01:06 >

# 9 Re: Really REALLY newbie here...
You've got a couple of things going on, most of these have been pointed out, but let's just review:
1. syntax errors (calling main() from main())
2. the project appears to be set up for mfc, and wants stdafx.h included (the error you're getting, and the advice about precomplied errors.)
The first is easily fixed, you've proably already done so... the 2nd is possible but you need to ensure that all of the setting are right and the appropiate lib's are included, etc...
The best bet is to start a new project using the app wizard, (File/new), select the Project tab, click the create new work space radio, find & select the Win32 console application, give it a name and a directory. Press ok. You should be presented with options to create an empty, simple, hello world, or MFC enabled application. Choose "Hello World", press ok and generate the project. Now, you can copy your code into the .cpp file that the project contains (just copy and insert the includes, and replace the existing code in main with your code from main, and leave stdafx.h). You can also have two VS's running one with your old project and the new one and you can examine the differences...
bytz at 2007-11-10 9:02:13 >

# 10 Re: Really REALLY newbie here...
i dont know what to tell you. if you chose win32 console as suggested it WILL work unless you've got something really messed up going on.
there shouldn't be an issue with MFC at all, the project wouldn't just add it. as someone else suggested please post the project zipped, otherwise it's impossible for us to locate your error.
# 11 Re: Really REALLY newbie here...
ok, basically it's very simple; like the people before said:
click File-New and select Win32 Console Application, enter a project name and click Next; select "A simple Hello World Application" and click finish;
then click Ctrl-F5 and it should work;
it's simple; i don't want to take any credit, cause the guys have already explained much better; i just thought this might be helpful...