Hi, I am trying to write an entire struct into the binary data file.
I have programmed this successfully in the past(way back) and I've also checked all on the internet but I cannot see the error in my code. For some reason this fails to write anything to my "business.dat" file. It is bugging me soo much since I know that my error is something small and very technical that I forgot.
You have two strings embedded in your struct. String is a complex data type containing a pointer to the memory that holds the string. When you try to write a std::string in this manner, you're writing the pointer, not the data.
Ahh yes of course. I have now reimplemented it in the simplest char array I could quickly think of. But I still get nothing written to the .dat file. I only am gonna repaste code I changed.
Thank you jlb. you make me think and I found the error. All was perfect excep in my numRecords function I should define ios::in instead if ios::out. That cleared the data file everytime i wanted to count the records.