problem about pointer

Status
Not open for further replies.

hiramlee

Junior Member level 1
Joined
May 15, 2012
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Chengdu,China
Activity points
1,408
int strcat(char *s, char *t){

while(*(s++)!='\0');
s--;
while(*(s++)=*(t++));

return 0;

}

Description Resource Path Location Type
Possible assignment in condition '*(s++)=*(t++)' strcat.c /strcat line 23 Semantic Error
Description Resource Path Location Type
suggest parentheses around assignment used as truth value [-Wparentheses] strcat.c /strcat line 23 C/C++ Problem
 

Code:
while(*(s++)=*(t++));

"=" is the assignment operator, you should use "==" for equality testing
 

ah! This function add the string t to the end of string s; so, here should be assignment operator "=", not "==".
Thanks all the way
 

In that case you can disregard the warning
Possible assignment in condition '*(s++)=*(t++)' strcat.c /strcat line 23 Semantic Error
because the compiler just tells you that it thinks you are using = instead of ==
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…