structures, pointers to structures, and the write() member function
Hello Everyone!!!
I have a serious problem. I know this may sound a bit amateurish, but I am really stuck. I have a dynamically allocated array of structures, and have to print it to a file using binary output. The problem is I keep getting a "Stack Exception" error in the "Write(1)...memorey address". Here is my current code:
outbin.write((char *)studRecPtr, sizeof(studRecPtr[loopIt]));
Any help would be highly appreciated. Thank you.
Re: structures, pointers to structures, and the write() member function
Quote:
Originally posted by 9933515
Hello Everyone!!!
I have a serious problem. I know this may sound a bit amateurish, but I am really stuck. I have a dynamically allocated array of structures, and have to print it to a file using binary output. The problem is I keep getting a "Stack Exception" error in the "Write(1)...memorey address". Here is my current code:
outbin.write((char *)studRecPtr, sizeof(studRecPtr[loopIt]));
Any help would be highly appreciated. Thank you.
You could try:
outbin.write((char*)studRecPtr, NrOfStructs * sizeof(STRUCTBASE));
if you have typedef:ed your struct
typedef struct
{
...
}STRUCTBASE;
STRUCTBASE* studRecPtr;