Comparison between pointer and integer in C

后端 未结 8 1320
盖世英雄少女心
盖世英雄少女心 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:10

    Here str[i] is a character an NULL is a pointer, so we can not compare it logically. Use '\0' to compare with str[i] as it is defined to be a null character, so comparing a character str[i] with a null character '\0' is a right method and will not through any warning.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题