So, I am very new to C and I am trying to terminate my program on an empty string (when the user presses enter with nothing there) but for some reason it is giving me an infinite loop.
Here is my code:
while(input[0] != '\0') {
if(slot < 27 && slot >= 0) {
struct LinkedList curr = files[slot];
if(strcmpci(input, curr.val) == 0) {
printf("%s, \n", curr.val);
}
while(curr.next != NULL) {
curr = (*(curr.next));
if(strcmpci(input, curr.val) == 0) {
printf("%s\n", curr.val);
}
}
}
}
and everywhere that I have went has told me to end my loop with this format
while(____ != '\0') {
}
so I am very confused.
inputnever actually changes inside your loop, so itinput[0] != '\0'the first time through the loop then it will be the same the second time and the third and the 710143rd time