I'm trying to work on my loading function still. I get 10 lines into an array, from a text file, and now need to insert a colon in the right spaces, and then send each to a list. I get a windows error message when I do this, and the problem is with the strcats. Here's my attempt:
First, here is this function:
And heres the problem code:Code:void SetUp() { for(int x=0; x<=10; x++) { times[x] = new char[50]; } char times[11][50]; } void DeleteVars() { for(int x=0; x<=10; x++) { delete[] times[x]; } }
Code:void LoadTimes() { ifstream load; load.open("times.txt"); //FILE* File; //File = fopen("times.txt", "rb"); //if(File != NULL) //MessageBox(NULL, "works", "test", MB_OK); for(int x=0; x<=10; x++) { load>>times[x]; //fread(×, sizeof(char*[11]), 1, File); } //fclose(File); load.close(); char* string = ""; char tempstring[10]; for(x=0; x<=10; x++) { tempstring[0] = times[x][2]; tempstring[1] = times[x][3]; tempstring[2] = times[x][4]; tempstring[3] = times[x][5]; strcat(string, (char*)times[x][0]); strcat(string, (char*)times[x][1]); strcat(string, ":"); strcat(string, (char*)times[x][2]); strcat(string, (char*)times[x][3]); strcat(string, ":"); strcat(string, (char*)times[x][4]); strcat(string, (char*)times[x][5]); SendDlgItemMessage(NULL, IDC_LIST, LB_ADDSTRING, x, (LPARAM)string); } }



LinkBack URL
About LinkBacks


