I wanted to make my own function that converts a string to lowercase,s and I want to be able to convert the result of tolower to a char but whenever I typecast it, it crashes. How would I fix this?
My function is as follows:
void stringToLower(char **str){
char *val = *str;
int i = 0;
int n;
for ( i = 0; val[i] != NULL; i++){
val[i] = (char)(tolower(val[i]) );
printf("%c", val[i]);
}
printf("\n");
return;
}
int main(){
char *name = "BILLY";
stringToLower(&name);
printf("%s", name);
return 0;
}