1#include <stdio.h>
2
3int main(){
4 char name[20];
5
6 printf("Enter a name : ");
7 scanf("%[^\n]%*c", &name);
8
9 printf("the name entered is: %s\n", name);
10
11return 0;
12}
1char name[30];
2char temp;
3
4printf("Enter age: ");
5scanf("%d", &age);
6printf("Enter name: ");
7scanf("%c", &temp); // temp statement to clear buffer
8scanf("%[^\n]", name); // read until newline
1#include <stdio.h>
2
3int main(){
4 char name[20];
5
6 printf("Enter a name : ");
7 fgets(name, 20, stdin); // fgets(variable_storing_to, accepted_input_size, stdin)
8
9 printf("the name entered is: %s\n", name);
10
11return 0;