Hello, I got a new computer over summer and I'm starting another semester of c++ programming in the fall, so I wrote a basic program to help refresh my memory before the class starter. I am using Microsoft Visual Studio Express 2012. My OS is Windows 7. Nothing builds, not even the basic 'Hello World' program.
When I try to build this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include stdafx.h
usingnamespace std;
int main()
{
double hours, rate, pay;
cout << "How many hours did you work? ";
cin >> hours;
cout << "How much do you get paid per hour? ";
cin >> rate
pay = hours * rate;
cout << "You have earned $" << pay << endl;
return 0;
}
I get this :
Warning 1 warning C4627: '#include <iostream>': skipped when looking for precompiled header use c:\users\chris\documents\visual studio 2012\projects\consoleapplication5\consoleapplication5\consoleapplication5.cpp 1 1 ConsoleApplication5
Error 2 error C2006: '#include' : expected a filename, found 'identifier' c:\users\chris\documents\visual studio 2012\projects\consoleapplication5\consoleapplication5\consoleapplication5.cpp 2 1 ConsoleApplication5
Error 3 error C1083: Cannot open include file: '': No such file or directory c:\users\chris\documents\visual studio 2012\projects\consoleapplication5\consoleapplication5\consoleapplication5.cpp 2 1 ConsoleApplication5
The class starts on monday and I would really like to figure out what is going on.
I think you have to get rid of stdafx.h which is a precompiled header file, so just delete it in your code. When you're making a project in visual studio you need to check empty project so stdafx.h isnt included.
If I try to compile without stdafx.h I get this error:
Error 2 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? c:\users\chris\documents\visual studio 2012\projects\consoleapplication5\consoleapplication5\consoleapplication5.cpp 19 1 ConsoleApplication5
edit: I skimmed through your post too fast, one second.
Fixed that but also ran into this problem when I try to build hello world:
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Users\Chris\Documents\Visual Studio 2012\Projects\ConsoleApplication6\Debug\ConsoleApplication6.exe'. Symbols loaded.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110d.dll'. Symbols loaded.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110d.dll'. Symbols loaded.
The program '[6128] ConsoleApplication6.exe' has exited with code 0 (0x0).
If you don't want to have use precompiled headers, I'm fairly certain there's an option somewhere to disable them. Can't remember where, though; been a while since I've used VS.
I rarely use precompiled headers when starting new VS projects, and still VS2015 insists on adding the files and the #include to the solution. It is part of the project wizard template apparently.