Hi..
I am creating a program that writes to a binary file and then reads from it. It also checks that if the file exists then append the file or else write a new file. But after writing the same file again and again as it crosses like 24 bytes it gives a segmentation error . In addition to that i m not able to read the file cout<<"Read:<<*readData<<endl;; gives me only first char.
why are u passig char ** to the file.read() method.
U must do
file.read((char*)readData,size);
And when u are printing *readData u are printing the first character only because readData is a pointer to a char and by doing *readData u are accessing the character ointed to by that address. Remeber how a string is represented. Char * will point to the first element of the string.
U have to do
@dkalita and @kbw.. I tried that .. that was the first thing i made but the only problem is that the output.bin is in human readable format, shouldnt it be in a binary format.Then i stumbeled upon something called c+ serialization... but i m getting a seg fault in that. Foreg: my string is I live in Buffalo. . It shows me the string I live in buffalo .. it should be in binary format isnt it?