Amazon.com Widgets scanf() single character (Program 6.7)
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 24, 2013, 04:20:08 PM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Programming in Objective-C, 4th edition
| |-+  Chapter 6
| | |-+  scanf() single character (Program 6.7)
Pages: [1]   Go Down
Print
Author Topic: scanf() single character (Program 6.7)  (Read 628 times)
[I code:forFun]
Newbie
*
Posts: 12






« on: July 26, 2012, 05:45:42 AM »

In the book, we are told that it is best to put a space before the %c in the scanf format string.  This will cause scanf to skip over any white space characters in the input.

My question is, what whitespace in the input are we talking about?
The program asks us to enter a character, we enter a character and press Return.  So, the only two things I can picture in the input are the character and the 'Return'.   I am not understanding exactly what whitespace is being skipped, and exactly where it is coming from.

All I know is my program acts goofy without the space (I combined examples 6.2 - 6.7 into one program, and it seems to be just right for re-creating the issue as mentioned in the book).
Logged
reidnez
Newbie
*
Posts: 5






« Reply #1 on: August 17, 2012, 07:22:48 PM »

The user could theoretically input a space or a return before the value.
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.