C examples for Language Basics:scanf
Illustrates how scanf() works when you specify a field width.
#include <stdio.h> int main(void) { char name1[11], name2[11]; int count;//from w w w . j a v a2s. co m printf("Please enter 2 names.\n"); count = scanf("%5s %10s",name1, name2); printf("I read the %d names %s and %s.\n", count, name1, name2); return 0; }