I'm trying to convert a C-String to all lower case wihout the use of tolower from ctype.h . Hower my code does not seem to work: I'm receiving a runtime error. What I'm trying to do is changing the ASCII value of the capitalized letters bij 'a' - 'A' which should convert those values to the ones for lower case as far as I'm aware.
#include <stdio.h>
void to_lower(char* k) {
char * temp = k;
while(*temp != 0) {
if(*temp > 'A' && *temp < 'Z') {
*temp += ('a' - 'A');
}
temp++;
}
}
int main() {
char * s = "ThiS Is AN eXaMpLe";
to_lower(s);
printf("%s",s);
}