我已经读过,返回的值scanf指示它是否能够读取和转换值。我已经使用返回值来检测输入是否为整数,但是输入是否4.5 scanf返回1而输入是否g scanf返回0。她是我的代码:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int x;
int ReturnedValue=scanf("%d",&x);
printf("Scanf Returned:%d",ReturnedValue);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在多篇不同的文章中,您建议使用返回的值scanf检测整数,但是为什么现在不起作用?