Trying to start using xcode but i have a small problem.
Some code to make sure it reads files in correctly:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <fstream>
usingnamespace std;
int main()
{ ifstream infile;
char num1,num2,num3,num4;
infile.open("test.txt");
if(infile.fail()){
cout<<"Failed to open file";
exit(1);
}
infile>>num1>>num2>>num3>>num4;
cout<<num1<<num2<<num3<<num4;
return 0;
}
Input:
1 2 3 4
6
7
8
9
Output:
6789
Now my problem is on line 8. My input file is integers but it reads and gives the correct output even if I define them as a char or string. I'm using TextEdit to make the input file and saving it as a plain text file. Anyone know of a way to correct this?