i cannot return the pointer.
#include<stdio.h>
char *str_chr(const char *str,int c){
while(*str++){
if(*str++==c){
return str;
}
}
return NULL;
}
int main(){
char str[200];
scanf("%s",str);
printf("%p",str_chr(str,'a'));
}
Last edited on
Since the type of str
is const char *
you cannot return it as char *
. So change the return type to
const char *str_chr(const char *str,int c){