【发布时间】:2016-02-24 18:02:47
【问题描述】:
我被分配将 txt 文件中的所有字符串转换为小写,然后将其输出到新的 txt 文件中,但我似乎无法在任何地方找到如何做到这一点。任何帮助都会非常感激!谢谢这是我到目前为止所拥有的,但最后有 y 所以我在想是否有更好的方法可以做到这一点,或者我是否可以删除顶部有两个点的 y..
#include<stdio.h>
#include<process.h>
void main() {
FILE *fp1, *fp2;
char a;
fp1 = fopen("test.txt", "r");
if (fp1 == NULL)
{
puts("cannot open this file");
exit(1);
}
fp2 = fopen("test1.txt", "w");
if (fp2 == NULL) {
puts("Not able to open this file");
fclose(fp1);
exit(1);
}
do
{
a = fgetc(fp1);
a = tolower(a);
fputc(a, fp2);
} while (a != EOF);
fcloseall();
getch();
}
【问题讨论】:
-
'我似乎在任何地方都找不到怎么做' - 真的吗?请张贴您到目前为止所做的事情,例如。您的 Google 搜索字符串。
-
按字符读写。忘记字符串。
-
edited 添加了我能找到的内容
-
'while (a != EOF);'太晚了:(