I have 2 classes, class CreateData and class SaveData.
CreateData does just that - it creates and uses a linked list with data std::string str_val;.
SaveData saves the current values in the CreateData list to a file in binary mode. AFAIK, to read/write in binary, it is necessary to use char*
as the fundamental type (
class SaveData has a nested structure struct save_data that holds all the necessary info to be saved. The number of nodes in the CreateData list varies over the course of the program, so the corresponding pointer-to-array of c-string variable in SaveData::save_data struct has to be dynamically allocated. I'm at a loss for how to do this. Any help would be greatly appreciated.
Sample code below:
I've tried many ways to implement this; however, I end up with errors every time (they always originate from the SaveData::getValues function.
invalid conversion from char** to const char**
invalid conversion from char* to char
error: assignment of read-only location '*(temp + ((unsigned int)i))
However, one persistent problem remains: (*p).processNode().c_str() returns constchar *, but temp[ROW][COL] is type char *.
I tried adding const_cast<char *> to the c_str() part, and the program came to a screeching halt (the program froze and the message box that says "such-and-such program encountered an error and needs to close. You can choose the send a technical report to Microsoft..." popped up).
I can't make temp constchar, as I would be unable to assign values.
or is there some other way to do it that I'm completely overlooking?
PS - I also need to be able to store this array in a structure and then write the contents of said structure to a file in binary mode, but the structure variable char ** NodeValues_; (line 40) should take care of that part, right?