I wrote a function to read an expression (i.e. A+B-C) from the keyboard one character at a time, and ignoring spaces insert each char into a queue. I tried something I though would be fairly elegant, but I don't think I did it right. This is my function:
void getExpression(QueueT Queue1)
{
char ch;
printf("\nEnter Expression:");
while ( (ch=getchar()) != "\n")
{
if (ch != " ")
{
insertQueue(Queue1, ch);
}
}
}
When I run it, the loop never exits. I've fed it all sorts of input trying to break the while condition, but no dice. I'm currently thinking that having (ch=getchar()) in my while condition isn't working like I think it is. Any tips would be much appreciated.
Also, this is my first post, so I apologize for any formatting errors.