首頁  >  問答  >  主體

c++ - a是多个字符和空格时,fscanf (fp,"%d",&a)调用之后,fp指针位置跳过空格吗?

比如

fp内容:"how are you";

fscanf (fp,"%d",&a);
fscanf (fp,"%d",&b);

a输出how
b输出are吗?
为什么第二次调用fscanf自动跳过空格?

PHP中文网PHP中文网2761 天前825

全部回覆(1)我來回復

  • 黄舟

    黄舟2017-04-17 15:06:03

    Whitespace character: the function will read and ignore any whitespace characters encountered before the next non-whitespace character (whitespace characters include spaces, newline and tab characters -- see isspace). A single whitespace in the format string validates any quantity of whitespace characters extracted from the stream (including none).
    http://www.cplusplus.com/refe...

    回覆
    0
  • 取消回覆