Currently, I'm trying to clean up the code so that I can rewrite the event and link parsers into something more effective, but ran into some problems with a function supposed to load the contents of a text file into an array of strings.
What works:
- The number of lines is correctly counted and stored in the counter the external function uses
- The array is created and the lines are loaded from the file into it
- The array contains the correct contents in the filetostrarray() function
What DOESN'T work:
- load_paragraph() doesn't have access to the strings in the array and crashes the program when trying to display them
In void load_paragraph():
string parfile=par_file(current_node); int lines; string *line; filetostrarray(parfile, &lines, line);In filetostrarray
void filetostrarray(string file, int* lines, string *readlines) {
*lines=lines_in_file(file);
if (*lines) { fstream line_in(file.c_str(), ios::in);
readlines=new string[*lines];
for (int i=0; i<*lines; i++) getline(line_in, readlines[i]);
line_in.close();
line_in.clear(); } }
Edited by the_fifth_horseman, 27 August 2010 - 07:03 PM.













