在C++中怎么把一个输入/输出流文件中的大写字母都变小写字母

来源:百度知道 编辑:UC知道 时间:2024/05/11 15:53:59
麻烦帮忙把WHILE里面的东西补充一下,谢谢了,o(∩_∩)o...

首先,需要包含这4个头文件
#include<cstring>
#include<iostream>
#include<string>
#include<fstream>

using namespace std;

const string fileName1 = ...; // 需要读取的文件
const string fileName2 = ...; // 需要写入的文件

从文件读取:
ifstream fin;
ofstream fout;

file1.open(fileName1);
file2.open(fileName2);
while (未到文件尾)
{
fin>>c;从file1读取一个字符;
使用 toLowerCase(读入的字符c)转换为小写;
fout<<c;输出转换后的字符至file2;
}

file1.close();
file2.close();

大致流程就是这样。

利用ascii码,把值范围在大写字母内的都加上32