I am completely perplexed as to why this doesn't work. I want to read in one line of an input .txt file as one long string and then print it. It seems to me that the most common way is to read it in as a C-String, but my main program(the code I have posted is just an example) will be much simpler if I can read it in as a normal c++ string. What am I doing wrong?
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char *argv[]){
ifstream inStream;
string line;
inStream.open(argv[1]);
getline(inStream, line, '\n');
inStream.close();
cout << line;
return 0;
}
When I run this, it outputs nothing. I am sure that my .txt file is inputted correctly and has characters in it.