Getchar and getche problem
-
Hi All I am using one console application and using getche and getchar function in this application. ch = getchar(); ch1 = getche(); I found that using getchar when I press enter I get value 10(LF) in ch. and when I press enter for getche() function i get value 13(CR) in ch1. Why am I not getting the same value in both function? When enter is pressed then two values are passed.that are 10(LF) and 13(CR). So value of ch1 must also be 10 in place of 13. Can anyone help me why I am getting different values in both functions. Thanks in advance BR Sachin Ahuja
-
Hi All I am using one console application and using getche and getchar function in this application. ch = getchar(); ch1 = getche(); I found that using getchar when I press enter I get value 10(LF) in ch. and when I press enter for getche() function i get value 13(CR) in ch1. Why am I not getting the same value in both function? When enter is pressed then two values are passed.that are 10(LF) and 13(CR). So value of ch1 must also be 10 in place of 13. Can anyone help me why I am getting different values in both functions. Thanks in advance BR Sachin Ahuja
Are you using both the function calls in a sequence? i mean one statement after the other? if Yes, Pressing "Enter" button does mean you are entering \r\n together into the stdin(keyboard) buffer.The first getchar() is returning the "\r". and the second getche() is returning the "\n" . can you test using getchar() once in your function and then, replace the getchar() with getche() and then verify result? regards, haribabu
-
Are you using both the function calls in a sequence? i mean one statement after the other? if Yes, Pressing "Enter" button does mean you are entering \r\n together into the stdin(keyboard) buffer.The first getchar() is returning the "\r". and the second getche() is returning the "\n" . can you test using getchar() once in your function and then, replace the getchar() with getche() and then verify result? regards, haribabu
Hi I have tried replacing getchar with getche in the function, but I am getting the same problem yet. Also I am not using getchar and getche in sequence. Rather I am using them in different functions. Please reply if you find some solution. Thanks Sachin Ahuja