Search code examples
cgetchar

can't compare getchar != '/n' , get warning: multi-character character constant


When I compare getchar() != '/n' I get the warning: multi-character character constant. I wounder why? I code in C and use gcc as compiler. I thought that getchar read in one character and converted it to int for itself. So what's the meaning of multi-character character constant?


Solution

  • '/n' is 2 characters I think you are looking for '\n'

    Getchar() will get 1 char '/n' is 2 characters (and because you defined the characters already it is a constant) so it is a multiple character character constant