int get_datasize(std::fstream& data) {
int start;
int end;
data.seekg(0, std::ios::beg);
start = data.tellg(); //sizeof start is output 0
data.seekg(0, std::ios::end);
end = data.tellg(); // sizeof end is output 4
return ((end - start) / sizeof(Student) ); // sizeof student is output 128
}
The resulting always got 0 for got data size, for more information the Student is struct type
Why the result always 0 for data size? Especially the program can add and writing new data to the file. I think the problem on the last line of the code, but I found not other solutions to solve this 0 data size
New contributor
Maryanto is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1