I'm having a very weird problem where when I put in the following code, it doesn't show any errors but cannot pass the linking part because it's not creating a .exe file. I can comment this whole section out, paste another source code in the same file, and it will compile fine to the debugger. When I comment the other code out and try this code, it gives me the error "unable to start program C:\...\lab10.exe the system cannot find the file specified.
I have tried completely typing the program again, both in the same file and creating a new project.
//#include <iostream>
//#include <iomanip>
////#include <Windows.h>
int main()
{
// cout << "How many miles have you traveled?\n";
// float fMiles = 0, fHours = 0;
// cin >> fMiles;
// while (fMiles < 0) {
// cout << "Invalid input of miles.\n";
//// Sleep(1000);
// system("cls");
// cout << "How many miles have you traveled?\n";
// cin >> fMiles;
// }
// cout << "How many hours have you been traveling?\n";
// cin >> fHours;
// while (fHours <= 0) {
// cout << "Invalid input of hours.\n";
//// Sleep(1000);
// system("cls");
// cout << "How many hours have you been traveling?\n";
// cin >> fHours;
// }
// cout << "\nYou were traveling at " << fixed << setprecision(2) << mph(fMiles, fHours) << " MPH";
//
// system("pause");
return 0;
}
When I put this in, the console will flash on the screen and go away. If I uncomment "#include < iostream>" then it gives the same error and won't compile.
That looks like the compiler was not installed or configured correctly. It doesn't know where to find either the include files (at compile time) or the library files (link time). You may be able to set the correct paths somewhere in the setup, or perhaps re-install the compiler.
It is a .cpp file. If I watch the target folder, the other projects I have written put an actual .exe file there during the compiling process. With #include <iostream> commented out, this program also puts a .exe file called lab10.exe. When I uncomment #include <iostream>, it destroys lab10.exe, then just puts a random .tmp file there. This particular time it was trzEAA6.tmp.
I'm thinking it is a compiler issue, but with the same file I can put in a different code and have it pop up something else fine.
Ok, I tried using windows to repair visual studio, to no avail.
I can run programs I wrote prior to the other day just fine. I am starting with an empty project. I wrote another one with just this:
I think I'm just going to have to wipe and reinstall visual studio, because I cannot find anything in the tools or the preferences that will help this.
I'm using Visual Studio 2012 pro (student license). After updating Windows 7, repairing visual studio, and re-booting about 17 times, the problem seems to have gone away... Thank you guys for your help.
I know this thread is solved but "solutions" like this really bother me. Are you sure there isn't anything that you did: an update, a system variable change, etc, that could have fixed this?