scanf in c and relation input buffer -
i try understand relation between scanf , input buffer. use scanf following format string: int z1,z2; scanf("%d %d", &z1,&z2); and try understand why can enter many possible whitespace (enter, blanks, tabs) after type in number 54 , press enter. as far understand every key press put in input buffer until press enter. so if type in 54 , press enter input buffer contains 3 elements, 2 digits , line break. buffer looks [5][4][\n] now scanf/formatstring evaluated left right. first %d matches 54, 54 stored in z1. because of whitespace in format string line break (\n) caused pressing first enter "consumed". so after evaluation of first %d , whitespace (\n) buffer empty again. now scanf tries evaluate second (and last) %d in format string. because buffer empty scanf waits further user input (user input = reads stdin in case keyboard). so buffer state/action sequence is buffer empty -> call of scanf -> scanf blocks user input --> us...