C examples for Language Basics:scanf
String Input from the Keyboard
#include <stdio.h> int main(void) { char initial[3] = {' '}; char name[80] = {' '}; printf("Enter your first initial: "); gets_s(initial, sizeof(initial)); printf("Enter your name: " ); gets_s(name, sizeof(name)); if(initial[0] != name[0]) printf("%s, you got your initial wrong.\n", name); else//from w w w.j av a 2 s .c o m printf("Hi, %s. Your initial is correct. Well done!\n", name); return 0; }