Hi all,
I am new to C on linux and have a question about I/O. I am trying to read input from the command-line:
printf("What is your first name? ");
scanf("%s", firstName);
printf("What is your last name? ");
scanf("%s", lastName);
printf("What is your age? ");
scanf("%d", &age);
printf("What street do you live on? ");
streetAddress = fgets(buffer, 255, stdin);
However, when I run this code after entering the "age", the code totally skips the "Enter Address" and continues with next line of code. I think there was a command in C++ to flush the input buffer. Does this command exist in C? And is this the best way to read a line of input?
Thanks in advance.