Illustrates how scanf() works when you specify a field width. - C Language Basics

C examples for Language Basics:scanf

Description

Illustrates how scanf() works when you specify a field width.

Demo Code

#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;
}

Result


Related Tutorials