0
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...

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Lucas Chan
  • 87
  • 6
  • Perhaps all you need is a good [`scanf` (and family) reference](http://en.cppreference.com/w/c/io/fscanf)? Please read about the `"%s"` format a little more. And no, newlines are irrelevant in this case. – Some programmer dude Mar 24 '18 at 11:55
  • To help you understand what's going on, why don't you simply print out the contents of `identity` after the second `scanf_s` call, to see what you actually read there? I recommend you take some time to [learn how to debug your programs](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/). – Some programmer dude Mar 24 '18 at 12:17
  • `scanf_s("%s", &name, 63);` only reads one "word", why expect it to do otherwise? – chux - Reinstate Monica Mar 24 '18 at 13:32

0 Answers0