Hi,
I want to implement a version of strlwr() but can't seem to be copying the lower case value back into the string.
My test program with the function looks like:
Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int strlwr(char* s)
{
char* tmp = s;
char r;
while (*tmp) {
printf("tmp %c\n",*tmp);
r = tolower(*tmp);
printf("r %c\n",r);
*tmp = r;
tmp++;
}
return 0;
}
int main (void)
{
char *addr = "AB:CD:EF:00:12:34";
printf("addr: %s\n", addr);
strlwr(addr);
printf("lower: %s\n", addr);
return 0;
}
and I get a seg fault at *tmp = r; but I don't undersatand why, any help would be greatly appreciated!
Thanks!