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
fscanf question
Started by boredaxel, Nov 09 2008 11:18 AM
2 replies to this topic
#1
Posted 09 November 2008 - 11:18 AM
|
|
|
#2
Posted 09 November 2008 - 12:42 PM
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
Posted 09 November 2008 - 06:44 PM
so if i leave out the whitespace, it will read in whitespace and newline in the data file as character? Is that it?


Sign In
Create Account


Back to top









