Using scanf() to input numeric and text data. - C Language Basics

C examples for Language Basics:scanf

Description

Using scanf() to input numeric and text data.

Demo Code

#include <stdio.h>

int main( void ){
    char lname[257], fname[257];
    int count, id_num;

    puts("Enter last name, first name, ID number separated \n");
    puts("by spaces, then press Enter.\n");

    /* Input the three data items. */

    count = scanf("%s%s%d", lname, fname, &id_num);

    printf("%d items entered: %s %s %d \n", count, fname, lname, id_num);

    return 0;/*from w w  w  .ja  v a  2s  .  co m*/
}

Result


Related Tutorials