while loop won't terminate with a logical conditional
This loop won't terminate if I add an OR conditional statement. If one is false, then it should terminate. //global var int x = 100; char *n= malloc (64); void add(void) { do { printf("Would you like to add 1? (y/n) "); fgets(n, 64, stdin); //removes newline n[strlen(n)-1] = '\0'; x++; } //if I add || (x!=100) it keeps looping me even if I press "n" //otherwise without it it works fine while((strncmp(n, "n", 1) != 0) || x!=100 ); free(n); } At the bottom of your loop, you're doing x++ . Once you hit the while condition, x == 101 , so your loop never terminates, x never equals 100 when the