c - buffer associated with input file stream -


this question has answer here:

how can see contents of buffer assocaited input file stream(stdin) . suppose if giving input using scanf, getchar or input function how getting stored in buffer. when press "enter" key .

example:

case:1)

$ input 2 integers: 10 20 (enter) $ input 2 integers: 10(enter) 20(enter)

case 2:

$enter 2 characters b(enter) $enter 2 characters a(enter) b(enter)

why in case 1 ignoring spacebar(asci-32) in case2 taking spacebar next input. propert of scanf function or terminal .

in first case
here ignoring space bar because, according ascii character set " space " character ascii value in decimal 32.
when "%d" encounters value 32 ignores because cannot integer since
integer literals have range between 48(0) , 57(9).

whereas

in second case use "%c" input characters space(ascii - 32) is
valid input, , not ignored.

you can use %d input characters have provide ascii value
character want input, eg:
if want enter , display 'a' character input must 65.

hope helps clear things bit.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -