c语言编程为什么输不出结果,这个是转换大小写的
#include"stdio.h"
#include"string.h"
void inv(char*s)
{for(size_t i=0;i<=strlen(s);i++)
if(*(s+i)>65&&*(s+i)<92)
*(s+i)+=32;
}
void main()
{ char *p;
printf("请输入要转换的字符串:");
gets(p);
inv(p);
puts(p);
}
各位大佬,哪里错了
很明显的错,你
char *p;
没有申请内存,它是个"野指针",它是不可用的
最简单的,改为
char p[1024];
热门标签: