将字符串小写转换为大写,输出到文件中出现乱码,求解释!
程序代码:[local]1[/local]#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE *fp;
int i=0;
char str[100];
if((fp=fopen("d:\\text.txt","w"))==NULL)
{
printf("cannot open");
exit(0);
}
printf("Iput the sting:\n");
gets(str);
while(str[i])
{
if(str[i]>='a'&&str[i]<='z')
str[i]+=32;
fputc(str[i],fp);
i++;
}
fclose(fp);
fp=fopen("d:\\text.txt","r");
fgets(str,100,fp);
printf("%s\n",str);
fclose(fp);
}









