Reputation: 101
I created a new directory & file using cmd (I don't think this has anything to do with it but I'm listing my steps) so I can start learning C++, I then opened the file in vscode and tested out this basic function:
#include <iostream>
using namespace std;
int main(){
cout << "test << endl;
return 0;
}
When I tried to run the code I received the following error:
PS C:\Programming\C & C++\C & C++ Stuff\Learning C++> cd "c:\Programming\C & C++\C & C++ Stuff\Learning C++\" ; if ($?) { g++ C++ Tutorial.cpp -o C++ Tutorial } ; if ($?) { .\C++ Tutorial }
g++.exe: error: C++: No such file or directory
g++.exe: error: Tutorial.cpp: No such file or directory
g++.exe: error: Tutorial: No such file or directory
g++.exe: fatal error: no input files
compilation terminated.
After receiving the error, I checked MinGW to make sure I had the proper C++ files installed, I checked my environment variable path to make sure nothing changed (albeit I don't know why anything would) and then I started troubleshooting by looking up the error code.
Well, between searches I decided to change the file name just because I didn't like "C++ Tutorial.cpp." I changed the file name to "test.cpp," tried to run the code again for no specific reason, and it worked. The only difference in the terminal result was the file name being highlighted as shown here:
I'd just like to know what caused this error to disappear and perhaps what caused it; I cannot find anything online similar to this. Thank you!
Upvotes: 0
Views: 76
Reputation: 101
Thanks to the two comments I realize what happened. The errors were caused because of the space in my file name; therefore, the errors were quite straight-forward. "C++" and "Tutorial" as separate parameters do not exist in the path, and changing the file name to "test.cpp" worked because the file name was treated as a single parameter, for which did exist in my directory.
Upvotes: 2