Hi
My case is i get the error on runtime while getting data from a file.
i get this error:
I use cygwin gcc package to compiled it.
here is the code that i thought it might the error area:
anyone helps?
My case is i get the error on runtime while getting data from a file.
i get this error:
Code:
Record of 12344 is found! 5 [main] testing 4272 _cygtls::handle_exceptions: Error while dumping state (probably corrupted stack) Segmentation fault (core dumped)
here is the code that i thought it might the error area:
Code:
char line[100]; char *title[] = {"Student ID", "Student Name", "Subject Code", "Mark"} printf("\nRecord of %s is found!\n", id); while(fgets(line, 100, ptr) != NULL) { // read line by line char word[20]; int n; int i; for(n = 0; n < strlen(line); n++) { if( line[n] == ' ' ) // See if it is a space { strncpy(word, line, n); line = strstr(line, " "); // get the whole line from first occurrances of " ". printf("%s : %s\n", title[i++], word); } } line = ""; // set the line to blank break; }
Comment