I have used function write() in a loop to write 2 names in binary mode to a file. Now, when I try to read those 2 names I use this logic : 1) find size of file in bytes; 2) create buffer with that size; 1) read into buffer until end of file; 4) print out buffer.
void read_from_bin1(const char *file_name,int size){
char *buffer = new char[size];
ifstream ispis(file_name);
while (!ispis.eof()){
cout << "Loop" << endl;
ispis.read(buffer, size);
}
cout << buffer << endl;
delete [] buffer;
buffer = nullptr;
}
The function stores only first name in buffer even though loop repats twice. I quess the problem is my lack of understanding this read() func. or there is something weird going on with this char*.