- Home /
This question was
closed Jan 10, 2013 at 06:07 PM by
whydoidoit for the following reason:
Question is off-topic or not relevant
Question by
CodrinH · Jan 10, 2013 at 05:26 PM ·
compilationc
C - compare 2 char
#include <stdio.h>
int main()
{
char a,b;
printf("Which character is greater?\n");
printf("Type a single character:");
a=getchar();
printf("Type another character:");
b=getchar();
if(a > b)
{
printf("‘%c’ is greater than ‘%c’!\n",a,b);
}
else if (b > a)
{
printf("‘%c’ is greater than ‘%c’!\n",b,a);
}
else
{
printf("Next time, don’t type the same character twice.");
}
return(0);
}
this is code is from the book " C for dummies "
the characters are compared by an if statement as well as by if-else. The greater of the two is then displayed.
the program gets compiled, but executing it, afhter the first simbol imputed skips to the IF statement, skping the 2'nd getchar. this way the items fail to compare.
where is the bug ? thank you
Comment
This board is not for general program$$anonymous$$g, it is devoted to Unity. And Unity doesn't speak C.
Follow this Question
Related Questions
No player movemnt HELP 0 Answers
Isn't there a "do not compile" folder? 6 Answers
Problème de compilation vers Android. 1 Answer
OnEnable - Script Hot Reload - Script Execution Order 1 Answer
clickable object 1 Answer