#include<stdio.h>
main()
{ FILE *fp;
char str[100];
int i=0;
if((fp=fopen("test","w"))==NULL)
{ printf("Can not open the file\n");
exit(0);
}
printf("Input a string:\n");
gets(str);
while(str[i]!='!')
{if(str[i]>='a'&&str[i]<='z')
str[i]=str[i]-32;
fputc(str[i],fp);
i++;
}
fclose(fp);
fp=fopen("test","t");
fgets(str,strlen(str)+1,fp);
printf("%s\n",str);
fclose(fp);
}
我刚开始学习C,我看着书自己解释了一部分,不知道对不对
/*定义一个指针变量fp */
/*定义一个长度100的数组*/
/*定义一个整型变量i并赋初值为零*/
/*打开名为test的文件并把地址赋给指针变量fp同时清空文件内容*/
/*满足循环条件则打印Can not open the file回车*/
/*否则推出循环*/
/*打印Input a string回车*/
/*输入一串字符回车后送入数组中*/
然后就是while循环,这个以后的部分我不是很明白,请指点我一下,谢谢