My printf is showing null ! May be I'm not being clear:
Say I've an i/p as :
1 2 3
1 2 4
2 3 4
separated by spaces and \n s.
Now I use Dave's code as:
I'm getting buffer as null.Is my syntax correct? Also what I want is after first iteration of while loop buffer should be as buffer=1, buffer=2 and buffer=3.
/*s is a single line i/p say 1 2 3 */
size_t len= strcspn(token," \n");
n = sprintf(buffer,"token[%2d] = %*.*s\n", i, (int)len, (int)len, token");
printf ("[%s] is a %d chars string\n",buffer,n);