I already read some posts about this, but I still can't fix my code.
int numericValue(char s, int i) {
if (strcmp(s[i], "$") == 0)
return 0;
else
return value(s[i]) + numericValue(s, i + 1);
}
This is my code, and if I change int numericValue(char s, int i)
for int numericValue(char *s, int i)
I have this warning:
passing argument 1 of 'strcmp' makes pointer from integer without a cast [-Wint-conversion].
What could I do?
If you just want to compare two characters use double equals sign(==) as below and mind those single quotes around dollar sign as character literals are enclosed in single quotes,
int numericValue(char* s, int i) {
if (s[i] == '$')
return 0;
else
return value(s[i]) + numericValue(s, i + 1);
}
One will use strcmp to compare two strings, but in your case you are passing a character to strcmp as first argument which is a mismatch. See strcmp signature below:
int strcmp(const char *s1, const char *s2);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.