Listing 3 This code controls the size of the items read by adding a field width to the format descriptor.

#include <stdio.h>

main()
{
    char *s = "hello there 12345.67089";
    char s1[6], s2[6], s3[6];
    int n1, n2, nargs;
    float f;

    nargs = sscanf(s,"%20s%3s%s%3d%5f%d",
      s1,s2,s3,&n1,&f,&n2);
    printf("%d: %s,%s,%s,%d,%f,%d\n",
      nargs,s1,s2,s3,n1,f,n2);
    return 0;
}

/*
OUTPUT
6: hello,the,re,123,45.669998,89
*/

/* End of File */