Having problems compiling my .cpp file on Linux
For some reason my code is not compiling on a linux server. It gives me several ofstream, ifstream, and fstream errors. It compiles perfectly fine on a windows machine. I have never tried to compile a c++ program on linux before so this could be a dumb mistake.
This is just a simple program that copies one file to another file and checks for different errors. Thanks for any help! Code:
#include <iostream> |
I have to admmit that the c++ compiler errors are sometimes somewhat hard to read, especially because very long type names and function prototypes. They are, however quite clear:
Code:
main.cpp: In function ‘bool fileExists(std::string)’: You can do this by calling the method string::c_str(). So, Code:
std::ifstream infile(fileName.c_str()); Code:
main.cpp:36:3: error: ‘system’ is not a member of ‘std’ Code:
#include <cstdlib> Another note: Code:
bool fileExists(const std::string); Code:
bool fileExists(const std::string&); |
Perfect! That fixed it.
And thanks for the reference suggestion. It's been a while since i've programmed in c++ so I didn't think that through all of the way. |
All times are GMT -5. The time now is 10:13 PM. |