【发布时间】:2014-12-06 19:17:40
【问题描述】:
我正在尝试编写一个程序: - 读取一个文本文件,然后将其放入一个字符串中 - 通过减去 4 来更改字符串中的每个字母 - 输出改变的行
我了解如何输入/输出文件。我没有比这更多的代码而且我很困惑,因为这对我来说是一个非常新的概念。我已经研究过,找不到直接的答案。如何将原始文件的每一行输入到一个字符串中然后进行修改?
谢谢!
// Lab 10
// programmed by Elijah
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
fstream dataFile;
//Set the file "coded" as the line input
dataFile.open("coded.txt", ios::in);
//Create the file "plain2" as program output
dataFile.open("plain2.txt", ios::out);
}
【问题讨论】:
标签: c++ input output file-handling