C examples for Language Basics:scanf
Using scanf() to input numeric and text data.
#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*/ }