Hi there,
Here is what I've tried:
the result is:Code:#include<stdio.h> int main(){ char str[10]; int a; fgets(str, 10, stdin); scanf("%d", &a); printf("str is %s and the int is %d.\n", str, a); }
The str is what I want but the int is not.$ ./test
abc 123 37482 <-- input
str is abc 123 3 and the int is 7482. <-- output
What I want is like this:
How can I achieve this?$ ./test
abc 123 37482 <-- input
123 <-- another input for the int
str is abc 123 3 and the int is 123. <-- output