Comparison between pointer and integer in C

后端 未结 8 1376
盖世英雄少女心
盖世英雄少女心 2021-01-05 06:00

I have a bit stupid question about program in C. My compiler says me: warning: comparison between pointer and integer. I really don\'t know why. I only want to writ

8条回答
  •  青春惊慌失措
    2021-01-05 06:15

    NULL should only be used in pointer contexts, but here you're comparing it to a character.

    You'd normally want something like:

    while (str[i] != '\0') {
    

    [or, of course, something like puts(str); or printf("%s", str);]

提交回复
热议问题