发布网友 发布时间:2024-10-24 10:01
共2个回答
热心网友 时间:2024-11-10 06:30
#include <stdio.h>
#include <stdlib.h>
char * translate(char *a)
{
int i=0;
while(a[i]!='!')
{
if((a[i]>='A')&&(a[i]<='Z'))
{
a[i]=a[i]+32;
}
i++;
}
return a;
}
void writeInFile(char *a)
{
FILE *fp;
int i=0;
if((fp=fopen("test.txt","w+"))==NULL)
{
printf("open file error!\n");
return;
}
while(a[i]!='!')
{
fputc(a[i++],fp);
}
printf("write in file successfully!\n");
fclose(fp);
}
int main()
{
char a[100];
int i=0;
printf("input String :\n");
do{
scanf("%c",&a[i++]);
}while(a[i-1]!='!');
translate(a);
i=0;
while(a[i]!='!')
{
printf("%c",a[i++]);
}
printf("\n");
writeInFile(a);
return 0;
}
热心网友 时间:2024-11-10 06:30
你是要用那种编程工具实现还是,描述的清晰一些。