I have to read say 10 file and then print out a report delimited by
":". No matter what I do to it, I either get the first record to print
or the last one.
I tried as suggested putting the for while loop inside the while loop and still no luck.
I think it's the for loop and I have tried everything that I know to do. Maybe I'm thinking too hard.
Here's the code :
Any suggetsions????Code:#include <stdio.h> #include <string.h> int main() { char customerString[120]; char *tokenPtr; int k; //char ch; printf("Login Id User Id Group Id User Name User Home Directory Starting Shell\n", "", "", "", ""); tokenPtr = strtok(customerString, ":"); for( k = 0; k < 5; k++) { gets(customerString); while ( tokenPtr != NULL) { printf("%s\t", tokenPtr); tokenPtr = strtok(NULL, ":"); } } //ch = getchar(); return 0; }//End main
Minor edit by Govtcheez - code tags end with [/code], not [\code]



LinkBack URL
About LinkBacks


