scanf 在以下情况下返回的值是多少:
int g;
int p = scanf("%d", &g); // Originally: int p = scanf("%d", g);
我知道签名scanf
函数是:
int scanf(const char *format, ...)
是什么int
该函数返回的值?
来自man
page:
NAME
scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf
...
RETURN VALUE
These functions return the number of input items successfully matched
and assigned, which can be fewer than provided for, or even zero in the
event of an early matching failure.
The value EOF is returned if the end of input is reached before either
the first successful conversion or a matching failure occurs. EOF is
also returned if a read error occurs, in which case the error indicator
for the stream (see ferror(3)) is set, and errno is set indicate the
error.
就你而言,scanf()
可以返回0
, 1
or EOF
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)