Question about the input of the c language scanf

Here is a code as an example, ask for the name now live

#include <stdio.h>

#include <windows.h>

#define MAX_NAME_LEN 5

#define MAX_PLACE_LEN 5

int main(void){

char name[MAX_NAME_LEN];

char place[MAX_PLACE_LEN];

printf ( "Please enter your name:");

scanf("%s",name);

printf ( "\ n Your name is% s", name);

printf ( "\ n Please enter your place of residence:");

gets(place);

printf ( "Your place of residence is% s", place);

 

system("pause");

return 0;

}

We enter: red

                 Beijing

Output is actually your name is red

Where you live is (here is empty, and output an empty string)

Why would this look like?

and

Guess you like

Origin www.cnblogs.com/Ybossy/p/12024072.html