Home > Back-end >  An error occurred when mixed input strings and Numbers
An error occurred when mixed input strings and Numbers

Time:03-20

1/* test while and used the scanf, when using different input will produce, */
2/* */the scanf function must be used in the input string array
3/* the scanf (" % s % d 12 ", the name, & amp; Input name + number + space can number), but the scanf (" % 12 s, % d ", the name, & amp; Number), after a way to enter name + space + comma + digital,
4 results are function returns a value of 0, only in lost full of 12 characters then play a comma and then lose number is valid, but "C Primer Plus" on page 79 of the second row in the table 4.7 write when it encounters the first blank
5 stops to enter to read the characters, */
6/* the scanf (" % s, % d ", the name, & amp; Number) enter exit not print anything, to change the order of the scanf (" % d, % s ", & amp; After the number, name) input can print, */
7 # include & lt; stdio.h>
8 int main (void)
9 {
10 char name [12].
11 int number;
12
12 13 the while (the scanf (" % s, % d ", the name, & amp; Number)==2)
Apple has 14 printf (" % s % d (s). \ n ", the name, number).
15 return 0;
16}
17
18

CodePudding user response:

Reference: https://blog.51cto.com/14058389/2337037
  • Related