Here I am again, and here is another question.
Again I'm trying to write replacement functions of exist ones in order to understand how C works. Here is my function, and it supposed to do a string conversion to lower cases:
Code:
int my_strlwr(char *str)
{
int i;
for (i = 0; *(str+i) != NULL; i++)
{
if (*(str+i) > 64 && *(str+i) < 91)
{
*(str+i) += 32;
}
}
return 0;
}
The test code is:
Code:
int main()
{
char *str = "Some";
my_strlwr(str);
printf("%s\n", str);
return 0;
}
Somehow when the program executes to that if statement, it crashes. Please help, thanks in advance.
ps: and I know the program is written in a crappy manner, I'll make it neater after the major problem is solved.