请教字符串赋值段错误问题
代码如下:#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void tolowercase(char* str1)
{
while(*str1 && *str1!='\0')
{
*str1 = tolower(*str1++);
}
*str1 = '\0';
}
int main(int argc, char *argv[])
{
char *a = "D";
tolowercase(a);
return 0;
}
调试报错:
Program received signal SIGSEGV, Segmentation fault.
0x080484e7 in tolowercase (str1=0x80485f1 "") at sendre.c:30
30 *str1 = tolower(*str1++);
请问问题是什么。谢谢~~