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
  • 506,650
  • 124
  • 909
  • 1,183
PixelRayn
  • 362
  • 1
  • 11

0 Answers0