Reading input from getchar() giving unexpected results
问题 I have a function which reads PIN from terminal and stores PIN and PIN length in the variables passed. On the first call to the function I get expected PIN and PIN length entered. However, during the second call to this function the first character is omitted. /* * Function : read_pin(char *pin,int *pin_len) * Description : Read entered PIN and stores PIN in pin and pin length in pin_len */ int read_pin(unsigned char *pin,unsigned int *pin_len) { int err = EXIT_SUCCESS; char ch; fflush(stdout