在目录中找不到文件[关闭]

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

您好,我正在尝试访问一个文件以在我的代码中打印行,但它给了我这个错误代码:

||=== Build file: "no target" in "no project" (compiler: unknown) ===|

C:\Users\user\Documents\final assignment.c|2|fatal error: iostream.f: No such file or directory|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

我想把我要访问的文本文件放在哪里。

 void affirmingfread(){
            fstream file;
            string text;

            file.open("affirmative.txt", ios::out);

            if (!file) {
                cout<<"File doesn’t exist.";
            } else {
                while (getline (file, text)) {
                  cout << text << endl;
                }
            }

我用了 3 个类似的函数来做这个。

c++ file directory file-handling
© www.soinside.com 2019 - 2024. All rights reserved.