string array to dat file issues

Hello there, i'm having difficulties when importing string array of 18 columns to dat file.
It crashes in 30% times... Why does it happen?
I guess it must be columns quantity.

Impossible to say without seeing the code.
its just simple set and get functions which take array and put to dat.. To dirty to be posted :)
At least show when you read from the file, or write to the file, whichever it is that is causing problems.

If you don't want to post the whole code (which you should try to avoid anyway if you have a lot of code) you could create a self-contained minimal example. So just remove everything that is irrelevant to the problem that you want to show. The code should still compile and run with the problem that you're having. In the process of doing this it's very likely that you will find the problem yourself, but if you still don't see what the problem is you can post it and we will probably be able to help you pretty easily (much more easily than if you had posted the whole program).
Last edited on
Sorry, but my crystal ball is in for service at the moment - so I can't foresee the code in question. So you'll need to post the code in question.
fstream saveToMain( "file.dat", ios::in | ios::out | ios::binary );

Database record;

saveToMain.seekg( ( 0 ) * sizeof( Database ) );
saveToMain.seekp( ( 0 ) * sizeof( Database ) );

id = "1000";
type = "regular";


saveToMain.write( reinterpret_cast< const char * >( &record ),
sizeof( Database ) );

I've tried to read from created dat file and I'm always having crashes.
Even if i use only three columns
What is the definition of Database?
Note that if Database contains pointers (or objects that contain pointers) then only the addresses stored in those pointers will be written to file. The actual data that the pointers point to will not be written.
Last edited on
Topic archived. No new replies allowed.