So I have a string containing student information which I've scanned in from a text file. Originally it looked something like this:
3800 Victor Lee; 2.8
3000 Joanne Brown; 4.0
1300 Frankie South; 2.6
I scanned them in using:
My output now looks like:Code:char** buildList (int size) { char** list; char temp[MAX_SIZE]; char* pFirst, *pLast; if(!(list = (char**)calloc (size + 1, sizeof(char*)))) MEM_ERROR; while((fgets(temp, sizeof(temp), fp1)) != NULL) { pFirst = temp + 5; pLast = strchr(temp, ';'); *pLast = '\0'; strcpy(temp, pFirst); strcat(temp, ","); fputs(temp, stdout); fputs("\n", stdout); }
Victor Lee,
Joanne Brown,
Frankie South,
Ultimately, it is supposed to resemble the format:
Lee, Victor
all other information is to be discarded.
I keep having trouble formatting it this way.
Anyone have any ideas?
All feedback is appreciated.



LinkBack URL
About LinkBacks


