I'm working on a program in C in which it will request a response, then use the first appearance of a digit (using isdigit() ) and then assign it to a variable for later use. After testing a bit I realized it was taking the ascii value for 10, which is line feed. Here is the code snippet.
while(isdigit(ch) == 0){
ch = getchar();
}
ch = getchar();
star = ch;//value is being detected as 10, which is line feed.
I tried casting ch to int when assigning it to star, which did not change the resulting value of 10. Is my issue within the assignment of ch, or is it poor syntax?