如何在C ++上读取多个文件

问题描述 投票:1回答:1

我的问题是:

首先读取一个名为symbols.txt的文件。该文件包含许多行,每行由2个元素组成:一个大写字母和一个字符串,此文件以哈希(#)结尾。

第二读一个名为dict.txt的文件。该文件包含许多单词(字符串)。以哈希(#

结尾

第三读了一个名为handin.txt的文件。该文件包含一些您将要处理的数字。以哈希(#

结尾

将输出打印到名为handout.txt的文件中>

这是我的代码,但是我不确定我是否正确读取输入内容。请帮我检查一下。非常感谢。

#include<bits/stdc++.h>
using namespace std;

int main() {

    freopen("symbols.txt" , "r" , stdin);

         //  input the letter and the string 

    char X ; string Y ;

    while(cin >> X >> Y && X != '#' )  {
         // my code goes here
    }

    freopen("dict.txt" , "r" , stdin) ;

          // input the strings here 

    freopen("handin.txt", "r" , stdin);

         // input the numbers here


    / *

          Here is my code 

    * /

    freopen("handout.txt" , "w" , stdout);

    // let in print the output here



}

我的问题是:首先读取一个名为symbols.txt的文件。该文件包含多行,每行包含2个元素:大写字母和字符串,该文件以hash(#)结尾。 ...

c++ readfile
1个回答
4
投票
#include<bits/stdc++.h>
© www.soinside.com 2019 - 2024. All rights reserved.