As a beginner, I have been typing away when I noticed OR (in C ||) broke the for loop. Here is the code:
#include <stdio.h>
int main() {
char ch;
printf("Typing program...\n");
printf("Type away:");
for(;;) {
ch = getchar();
if(ch == '~' || '`') {
break;
}
}
return(0);
}
When compiled the code doesn't seem to return any errors, but the for loop breaks when I paste the right side of the OR operator. What could cause this? Code is from C for Dummies, while I was doing an "exercise". Everything that I tried else would result in an error.
Aucun commentaire:
Enregistrer un commentaire