Someone please tell me why the loop here doesn't read the .txt file properly, but when I manually type it out in 81 lines of code, it does. I'll post the code with the loop first, then the one with manual entry second. The first code reads 2 spaces first, then cuts off the last 2 characters in the file. The second code works properly, reading and displaying all 81 characters that are contained in the .txt file.
#include <iostream>
#include <fstream>
#include <string>
usingnamespace std;
int main()
{
constint RANGE=81;
int inc,counter;
char number[RANGE];
ifstream sudoku ("sudoku.txt");
if (!sudoku)
{
cout<<"No such file."<<endl;
return -1;
}
while (!sudoku.eof())
{
sudoku.get(number[counter++]);
}
counter=0;
cout<<number[counter++];
cout<<number[counter++];
cout<<number[counter++];
cout<<number[counter++];
cout<<number[counter++];
cout<<number[counter++];
// I'd just put this line in 81 times and it would display correctly.
return 0;
}