Testing for the presence of a character in an string in C
- by Prab
What's wrong with this?
#include <stdio.h>
void main(){
char *s="some text";
printf("%d",is_in(s,'t'));
}
int is_in(char *s, char c){
while(*s){
if(*s==c) return 1;
s++;
}
return 0;
}
I get the following compile time error with GCC:
test.c:9: error: conflicting types for ‘is_in’
test.c:9: note: an argument type that has a default promotion can’t match an empty parameter name list declaration
test.c:5: note: previous implicit declaration of ‘is_in’ was here