Opening a .txt file using codelite?
Posted: Wed Nov 13, 2013 6:58 am
Have some really basic code, but can't seem to open a .txt file. The file is in the same directory as my .cpp and .h files (in the project folder) on my computer.
Here is the code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string tmpString;
ifstream myFile ("myText.txt");
cout << myFile.is_open() << endl;
if (myFile.is_open()) {
while (getline(myFile, tmpString)) {
cout << tmpString << endl;
}
myFile.close();
}
else cout << "Unable to open file." << endl;
return 0;
}
Could it be because my code can't see the .txt file through Codelite?
Here is the code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string tmpString;
ifstream myFile ("myText.txt");
cout << myFile.is_open() << endl;
if (myFile.is_open()) {
while (getline(myFile, tmpString)) {
cout << tmpString << endl;
}
myFile.close();
}
else cout << "Unable to open file." << endl;
return 0;
}
Could it be because my code can't see the .txt file through Codelite?