It's something like this:
When the program gets to the iofile line, segmentation fault. I was never good at pointers. What am I doing wrong?Code:MyStruct *mystructvar;
cin << mystructvar->value;
file >> mystructvar->value;
Printable View
It's something like this:
When the program gets to the iofile line, segmentation fault. I was never good at pointers. What am I doing wrong?Code:MyStruct *mystructvar;
cin << mystructvar->value;
file >> mystructvar->value;
You must allocate memory to a pointer first (unless you point to it to memory you've already allocated).
MyStruct* mystructvar = new MyStruct;
Man, that's all? Now I'm embarrased that I spent an hour trying to fix this problem before I posted here. :(
I knew that. I did, honest.
Thanks for the help, by the way.