0

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...

4
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by abhikkumarbasu
0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.