how to ignore whitespaces in fscanf()

后端 未结 3 803
暖寄归人
暖寄归人 2021-01-18 08:33

I need to use fscanf to ignore all the white spaces and to not keep it. I tried to use something like the combination between (*) and [^\\n]<

3条回答
  •  孤城傲影
    2021-01-18 08:56

    from the fscanf man page:

       A directive is one of the following:
      ·      A sequence of white-space characters (space, tab, newline, etc.;
              see isspace(3)).  This directive matches  any  amount  of  white
              space, including none, in the input.
    

    so

    fscanf(file, " %s\n");
    

    will skip all whitespace before reading in characters.

提交回复
热议问题