• 关于Scanf的返回值问题


    The C Programming Language says:

    Scanf stops when it exhausts its format string, or when some input fails to match the control specification.

    It returns as its value the number of successfully matched and assigned input items.

    On end of file, EOF(-1) is returned; note that it is defferent from 0, which means that the next input character does not match the first specification in the format string.

    经测试,该scanf这类库函数在不同编译环境中,得到的结果是不一样的。比如在VS2012中,只要能够成功读取一位(或多位),其返回值为1,而非成功读取的个数。即使格式串中有多位,但只成功读取到一位,仍然返回1。因此,其可移植性并不是很好,对吧?

  • 相关阅读:
    NOI2015 小园丁和老司机
    退役记
    留言板
    $mathfrak {reputation}$
    计算几何基础
    HNOI2018简要题解
    JXOI2018简要题解
    BJOI2018简要题解
    HAOI2018 简要题解
    CQOI2018简要题解
  • 原文地址:https://www.cnblogs.com/limeina/p/3685128.html
Copyright © 2020-2023  润新知