用c做leetcode的时候经常出现这种报错,原因是数组访问越界 char a = (char)malloc(sizeof(char)n); 这一步申请空间错了,应该是(sizeof(char)(n+1)); 最后空间存’\0’