I have this code
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char **argv) {
ifstream in;
in.open(*(argv+1));
char c;
while (true) {
if (in.eof())
break;
c = in.get();
cout << c;
}
in.close();
return 0;
}
I read the file which is passed via the command line as the first argument. While reading the file, I get the char '?' as the last one. Why?
If I remove this line
in.open(*(argv+1));
I will get only the char '?'.