python从键盘输入一个字符串、将小写字母全部_从键盘输入一个字符串_将其中的小写字母全部转换成大写字母...

从键盘输入一个字符串,

将其中的小写字母全部转换成大写字母,

然后输出到一个磁盘文件

“test”

中保存。输入的字符串以

结束

.

我写的程序是

#include 

#include 

#include 

void main ()

{

char str[100];

int i;

FILE*fp;

if((fp=fopen("test.c","w"))==NULL))

{

printf("Can not open the file\n");

exit(0);

}

printf("

请输入一组字符串

");

scanf("%s",str);

for(i=0;str[i]!='!';i++)

{

if(str[i]>='a'&&str[i]<='z')

str[i]=str[i]-('z'-'Z');

fputc(str[i],fp);

}

fclose(fp);

fp=fopen(srt[i],

r

);

fgets(str,strlen(str[i])+1,fp)

printf(

%s

,str[i]);

fclose(fp);

}