Warning comparison between pointer and integer

后端 未结 3 2037
无人共我
无人共我 2021-02-04 01:57

I am getting a warning when I iterate through the character pointer and check when the pointer reaches the null terminator.

 const char* message = \"hi\";

 //I         


        
3条回答
  •  死守一世寂寞
    2021-02-04 02:35

    It should be

    if (*message == '\0')
    

    In C, simple quotes delimit a single character whereas double quotes are for strings.

提交回复
热议问题