Code
main()
{ char ch;
int opnd;
write_message("Operand Test");
while ((ch = getchar()) != 'q')
{
if (ch == '\n')
{
write_char(ch);
break;
}
opnd = get_opnd(ch);
write_debug(opnd);
}
}
for every valid input, i pass the input to a function, print the results, and grab a new input. if input is a newline character, i want to pass it to another function and break from the loop. for whatever reason, the newline character isn't getting recognized by the if statement and it's still getting passed to the second half of the loop. even with "!= '\n'" parameters on the second part of the loop, the newline character is still going through
i put debugging statements in the function and throughout the driver but i have no idea why it's acting like that. if i take out the if statement and leave the "write_char()" function in the loop, inputing a newline will give me the correct output for the function so i don't see why it's not getting recognized in the if statement parameter. any idea on where my problem is or what else i could do to check?