scanf函数返回什么? [英] What does the scanf function return?

查看:68
本文介绍了scanf函数返回什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 scanf 函数的签名是:

int scanf(const char *format, ...)

此函数返回的 int 值是什么?

What is the int value returned from this function?

推荐答案

man 页面上:

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 EOF .

In your case, scanf() can return 0, 1 or EOF.

这篇关于scanf函数返回什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆