October 21st, 2013, 08:22 AM
I corrected the post to state POD types.
Regards,
Paul McKenzie
October 21st, 2013, 04:50 AM
Unlike other computer languages, when you make a mistake in C++, you are not guaranteed anything will work correctly, as D_Drmmr stated.
C++ doesn't work that way. That code could run on 1,000...
October 20th, 2013, 11:02 PM
To prove my point, try this program:
#include <iostream>
#include <string>
#include <fstream>
class FileIO
{
public:
October 20th, 2013, 10:38 PM
It doesn't work fine.
#include <iostream>
using namespace std;
class FileIO
{
public:
int numInt;
October 20th, 2013, 12:51 PM
How is a general method going to know what your object consists of? You still have to write the code to output the contents to a file, and write the code to read the file. There are no shortcuts. ...
October 17th, 2013, 03:13 PM
Then you open up your code to an issue of buffer overrun if you now switch your struct to using char arrays.
The issue is that you used a link that shows how to save 'C'-style or POD (Plain Old...
October 17th, 2013, 04:56 AM
If what you see in the file is gibberish, then you didn't save correctly. Reading gibberish will not turn it into any coherent.
D_Drmmr gave the reason for the issue -- you must save data to a...