//如何读写文件字符,使用gets(),puts(),fgets(),fputc()函数 //gets()函数用来从标准输入设备(键盘)读取串直到换行符结束,但换行符会被丢弃,然后在末尾添加'\0'字符,和puts配合使用 //从严格程度讲,gets(s)函数#include #include int main(){FILE *fp;char str[100];if ((fp = fopen("al", "w")) == NULL){printf("can not open file\n");exit(0);}printf("input a string:");gets(str);printf("debug:");puts(str);int i=0;while (str[i] != '!'){if (str[i] >= 'a'&&str[i] <= 'z'){str[i] = str[i] - 32;fputc(str[i], fp);}i++;}fclose(fp);if ((fp = fopen("al", "r")) == NULL){printf("can not open file\n");exit(0);}fgets(str, strlen(str) + 1, fp);printf("%s\n", str);fclose(fp);return 0;}