void load(char str[100])
{int i = 0;FILE* pf = fopen("count.txt", "r");if (pf == NULL){perror("error:");return 1;}printf("把字符转成大写后\n");while (fscanf(pf,"%s",str)!=EOF){for (i = 0; str[i] != '\0'; i++){if (str[i] >= 'a' && str[i] <= 'z'){str[i] -= 32;//小写和大写相差32}}printf("%s", str);//循环完输出内容}fclose(pf);
}
int main()
{char str[100];FILE* pf = fopen("count.txt", "w");if (pf == NULL){perror("error:");return 1;}int flag = 1;//用来判断while (flag == 1){printf("请输入字符串\n");gets(str);fprintf(pf, "%s", str);printf("输入J停止输入,输入其他字符继续接收字符\n");char c = getchar();getchar();//getchat的最后会有个\n,需要接收if (c == 'J'){flag = 0;//跳出循环}printf("\n");}fclose(pf);load(str);return 0;
}