Jump to content

fscanf question

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
boredaxel

boredaxel

    Newbie

  • Members
  • PipPip
  • 10 posts
I was doing some elementary programming and I find it werid that fscanf(abc, "%c"....) is different from fscanf(abc, "%c "...). Can anyone enlighted me on the difference a space after %c makes?? Im confused. Thanks alot

#2
dcs

dcs

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 775 posts
Question 12.17

Quote

Perhaps surprisingly, \n in a scanf format string does not mean to expect a newline, but rather to read and discard characters as long as each is a whitespace character. (In fact, any whitespace character in a scanf format string means to read and discard whitespace characters. [footnote] Furthermore, formats like %d also discard leading whitespace, so you usually don't need explicit whitespace in scanf format strings at all.)


#3
boredaxel

boredaxel

    Newbie

  • Members
  • PipPip
  • 10 posts
so if i leave out the whitespace, it will read in whitespace and newline in the data file as character? Is that it?