Reference from: https://www.douban.com/note/220299804/
There are three scenarios for the return value of the scanf function:
(1) The first is to return a positive integer representing the number of successful elements entered.
(2) The second type if the value returned is 0, which means that the input mismatch does not correctly enter any value, so the following code is available.
(3) The third return-1 (EOF) is the end of the input stream. Windows:ctrl + Z means end of input, Linux:ctrl + D.
The return value of the printf function is the number of output elements. printf ("%d\n", 1); 2
#include <stdio.h>#include<string.h>intMain () {intnum[ -]; for(inti =0; I <Ten; i++)//input:1 2 3 4?? 6 7 8 9 0 { if(SCANF ("%d", &num[i]) = =0) {scanf ("?"); Num[i]= -1; } } for(inti =0; I <Ten; i++) { if(I! =0) printf (" "); printf ("%d", Num[i]); } printf ("\ n");//output:1 2 3 4-1-1 6 7 8 9 0 return 0;}
Plus one:
The storage of the two-dimensional array in memory is continuous, so there is the following code.
#include <stdio.h>#include<string.h>intMain () {intLen; Charstr[Ten][1]; scanf ("%s", str[0]);//ABCDELen = strlen (str[0]); printf ("%d", Len);//5 Because the storage of two-bit arrays is contiguous in memoryPuts (str[0]);//ABCDE return 0;}
The return value of the scanf,printf function