Home > Software design >  Scanf keeps couldn't receive inputs with space in it. How can i use scanf to receive first and
Scanf keeps couldn't receive inputs with space in it. How can i use scanf to receive first and

Time:11-15

printf("\nEnter your age: ");
scanf("%d", &age);

printf("Enter name: ");
scanf("%c", &name);// first name and last name (**problem occurs here**)
            
printf("\nEnter your middle name: ");// this line skipped
scanf("%s", &middle);
            
           

CodePudding user response:

Use gets(variable name); instead

CodePudding user response:

use scanf(" %[^\n]",variable name);

  • Related