How do you write and/or read a character array to a file using a binary file stream. Thank you.
How do you write and/or read a character array to a file using a binary file stream. Thank you.
As I said, all your records must be the same length. But lets say the only thing you want to write is an array of characters that is 20 characters long.
char array[20];
memset(array,0,sizeof(array));
strcpy(array,"IfYouSaySo");
ofstream of;
of.open("file.dat", ios_base:ut, ios_base::binary);
// if you wanted to write to a different offset than 0, use
// seekp member:
// of.seekp( sizeof(array) * 3, ios_base::beg );
of.write(array, sizeof(array));
of.close();
The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.