0

I have a very simple 9 line program:

# include <stdio.h>

void main() {
    char input[20];
    scanf("%s20", input);

    while (input != "stop") {
      printf("%s\n", input);
      scanf("%s20", input);
    }
}

I am first reading a string from the user and then echoing it back. This works fine. However when the program receives the string "stop" i would expect the while-loop to terminate. It does not and I have to stop the loop with Ctr+C. Why is that?

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
PixelRayn
  • 392
  • 2
  • 13

0 Answers0