C user input ⌨️

Your video will begin in 10
72 Views
Published
C how to accept user input scanf fgets tutorial example explained

#C #user #input

char name[25]; //bytes
int age;

printf("\nWhat's your name?");
//scanf("%s", &name);
fgets(name, 25, stdin);
name[strlen(name)-1] = '\0';

printf("How old are you?");
scanf("%d", &age);

printf("\nHello %s, how are you?", name);
printf("\nYou are %d years old", age);
Category
Bro Code
Tags
c programming, c basics, taking
Be the first to comment