An integer variable num is defined, and now it is necessary to save the third shaping into it. How to write the numerical value entered with the scanf () function?
int n; n = scanf("%d ",& ampx); If (n== 1) printf ("successfully read an integer"); Else printf ("I failed, I didn't look at the numbers"); If you enter a string or something like that, the stored data is of type %d, because this is the format you specified for format reading. You also need to use the return value of the function to judge whether the reading is successful or not. If the reading is successful, the integer is received; if it is unsuccessful, there is nothing in X. For example, the input string is 123AB, X reads 123, and the extra AB remains in the input stream. For example, if the input string is AB 123, the reading statement fails, and X does not read anything.