second scanf_s would skip if the first scanf_s contains more than one words

63 Views Asked by At
void main() {

    char name[64], identity[64];

    printf("Welcome to ABC Computer Store!\n");
    printf("Please enter your name: ");
    scanf_s("%s", &name, 63);

    printf("Please enter your IC/Passport: ");
    scanf_s("%s", &identity, 63);
}

whenever user input more than one word, it will skip the second scanf_s. for example, when it ask for "Please enter your name: " and if user input "John" it would be fine, however if user input "John Cena" the second scanf_s that ask for IC/Passport, it would skip it, I know this has something to do with the next line \n Enter button issue, but I just can't fix it...

0

There are 0 best solutions below