回复 9楼 lwb603569640
你的能编译通过啊?为什么用getchar不行,用gets就可以呢?
程序代码:#include<stdio.h>
#include<stdlib.h>
//转换
void chang(char *str)
{
while(*str!='\0'){
if((*str>='A') && (*str<='Z')){
*str='*';
}
str++;
}
}
int main()
{
char *str1, *str2, *str3;
str1=malloc(100);
str3=str2=str1;
printf("输入字符串: ");
while((*str1=getchar())!='\n'){
str1++;
}
*str1='\0';
chang(str2);
printf("%s\n",str3);
free(str1);
return 0;
}

程序代码:#include<stdio.h>
#include<stdlib.h>
//转换
void chang(char *str)
{
while(*str!='\0'){
if((*str>='A') && (*str<='Z')){
*str='*';
}
str++;
}
}
int main()
{
char *str1, *str2, *str3;
str1=malloc(100);
str3=str2=str1;
printf("输入字符串: ");
while((*str1=getchar())!='\n'){
str1++;
}
*str1='\0';
chang(str2);
printf("%s\n",str3);
free(str1);
return 0;
}


程序代码:#include<stdio.h>
#include<stdlib.h>
//转换
void chang(char *str)
{
while(*str!='\0'){
if((*str>='A') && (*str<='Z')){
*str='*';
}
str++;
}
}
int main()
{
char *str1, *str2, *str3;
str1=(char *)malloc(100);
str3=str2=str1;
printf("输入字符串: ");
while((*str1=getchar())!='\n'){
str1++;
}
*str1='\0';
chang(str2);
printf("%s\n",str3);
free(str1);
return 0;
}
