Why does my code keep printing twice? I don't understand the problem [duplicate]
问题 This question already has answers here : How do you allow spaces to be entered using scanf? (11 answers) Closed last year . #include <stdio.h> #define MAX_STRING_LENGTH 1024 int main(){ char input_name_string[MAX_STRING_LENGTH+1],motive_string[MAX_STRING_LENGTH+1]; printf("What is your name?\n"); scanf("%1024s",input_name_string); printf("your name is %s \n", input_name_string); printf("What is your motive?\n"); scanf(" %1024s",motive_string); printf("your motive is %s \n", motive_string);