问题
I've reinstalled Visual Studio 2010 Professional several times to try to get it to work. I had to uninstall Visual Studio 2012 Professional because it wasn't compiling something we did in class.
I completely uninstalled everything including SQL Server..
I went to VC/include and the iostream header file is not there.
#include <iostream>
int main () {
cout << "hello";
system ("PAUSE");
return 0;
}
This is all I'm trying to do because nothing else is working.
It's really driving me crazy because I need to get it working so that I can do my project!!!
Every time I do; new project => empty project => add an item to source =>.cpp
I'm running windows 8.
It just says Error cannot open source file Also, error cout identifier is undefined....
I'm wondering if I should do a system restore? Or if I should just completely reinstall windows 8 from my recovery media?
回答1:
One problem is that you did not include the namespace std
.
This is what your code should look like:
#include <iostream>
using namespace std;
int main (void) {
cout << "hello" << endl;
system("pause");
return 0;
}
or you could have done something like this: std::cout << "Hello" << std::endl;
This may be a problem because you did not set your environment to C++. This is how you do it:
- Go to Tools > Import and Export settings. If you cannot find it, just search for it in Quick Search
- Then go to reset all settings.
- Then simply select "Visual C++"
- Restart.
That should do the trick. If it does not, you might consider re-installing Visual C++ itself. For VS 2012. If that does not work, then re-install the program.
回答2:
if it is problem with visual studio 2012, install this update.
来源:https://stackoverflow.com/questions/15181537/fatal-error-c1083-cannot-open-include-file-iostream-no-such-file-or-directo