#include <stdio.h>
int main()
{
char s[20];
char *p;
printf("please input string:\n");
scanf("%s",s);
p=s;
while(*p!='\0')
{
if(*p>='A'&&*p<='Z')
p=p+'a'-'A';
p++;
}
p='\0';
while(*p!='\0')
{
putchar(s);
p++;
}
printf("\n");
return 0;
}
题主可尝试下面方法
代码实现:
#include<stdio.h>
int main()
{
char s[100],*p;
printf("请输入字符串:");//printf("please input string:\n");
gets(s);
p=s;
while(*p)
{
if(*p>='A'&&*p<='Z')*p+=32;
p++;
}
puts(s);
return 0;
}
运行结果如图: