为什么从文件里读出来的数打印出来是笑脸呢(注:文件里的数为aaaGGG)
#include <stdio.h>#include <stdlib.h>
int main()
{
FILE *fp;
char ch,str[10];
int i=0;
fp=fopen("E:\\filename.txt","r");
if(fp==NULL)
{
printf("Can't open the file!\n");
exit(0);
}
while(ch=fgetc(fp)!=EOF)
{
str[i]=ch;
i++;
}
for(i=0;str[i]!='\0';i++)
{
if(str[i]>='a'&&str[i]<='z')
{
str[i]=str[i]-('a'-'A');
}
if(str[i]>='A'&&str[i]<='Z')
{
str[i]=str[i]+('a'-'A');
}
}
printf("%s",str);
return 0;
}