c - Warning comparison between pointer and integer

c – Warning comparison between pointer and integer

c – Warning comparison between pointer and integer

It should be

if (*message == �)

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

This: is a string, not a character. A character uses single quotes, like .

c – Warning comparison between pointer and integer

In this line …

if (*message == �) {

… as you can see in the warning …

warning: comparison between pointer and integer
      (int and char *)

… you are actually comparing an int with a char *, or more specifically, an int with an address to a char.

To fix this, use one of the following:

if(*message == �) ...
if(message[0] == �) ...
if(!*message) ...

On a side note, if youd like to compare strings you should use strcmp or strncmp, found in string.h.

Related posts on Integer :

Leave a Reply

Your email address will not be published.