I created a function to compare string value with spaces
It gives me error: warning: passing arg 1 of `strcmp' from incompatible pointer type and
passing arg 2 of `strcmp' makes pointer from integer without a cast

char *operand(node *pt)
{
  while(strcmp(pt->next, ' ')!=0)
    {
      strcpy(operand, pt->item);
      operand(pt->next);
    }
}

One of my friend tell me to replace ' ', with " ". But it doesn't work too...

Recommended Answers

All 3 Replies

In strcmp you are passing a pointer of node where you should pass a pointer of char.

Also the second operand really must be changed from
while(strcmp(pt->next, ' ')!=0)
to
while(strcmp(pt->next, " ")!=0)
because C-compiler treats ' ' as an integer and strcmp() does not expect an integer.

Your error is right here :-

while(strcmp(pt->next, ' ')!=0)

Because it will be while(strcmp(pt->next, ' ')!='\0')

The loop will continue till it finds the null character which is the default unseen character....

ENJOY

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.