参考这个博客,https://blog.csdn.net/sinat_40936062/article/details/84348021
1 #include<stdio.h> 2 3 int main(void) 4 { 5 int t; 6 if (scanf_s("%d", &t) == 1) 7 { 8 printf("%d ", t); 9 } 10 else 11 { 12 printf("Failed to read integer. "); 13 } 14 15 return 0; 16 }