Try this:
int auxNum;
char auxArray[kARRAY];
fi.get(auxArray, kARRAY);
Вопрос
Before you ask me if I have searched information before making this post (because I know you are going to ask it), yes, I did.
I'm doing a program where I load data after having saved them in a binary file. I have problems when I try to read the data from the binary file, and after being looking for hours what fails, I still do not know what is.
First, I store the information in the binary file:
ofstream of;
of << s.num;
of << s.array;
Where num is an int and array is a char array[kARRAY]
And then I try to read it this way:
ifstream fi;
int auxNum;
char auxArray[kARRAY];
fi >> auxNum;
fi >> auxArray;
Once I have read the information from the binary file, I try to assign that values to another variable of the same type, but I get errors and more errors...
char arrayResult[kARRAY];
arrayResult = auxArray;
What I'm doing wrong? Should I use specific functions due to the fact that I'm reading from a binary file?
Thanks!
Нет правильного решения
Другие советы
Try this:
int auxNum;
char auxArray[kARRAY];
fi.get(auxArray, kARRAY);