ifstream

    1熱度

    1回答

    我有一個保存用戶名的程序,它的讀取用戶名功能不斷給這個錯誤: Severity Code Description Project File Line Suppression State Error C2661 'std::basic_ifstream>::open': no overloaded function takes 0 arguments ConsoleApplication3 c:\u

    -1熱度

    3回答

    我很慚愧,因爲無法解決這個問題,但我無法完成這項工作。我有這個簡短的測試: std::string archnom = "../data/uniform.txt"; ifstream archin(archnom.c_str()); ASSERT(archin.good()); 斷言是拋出錯誤。由於某種原因,它沒有找到uniform.txt文件。該項目的結構: ​​ 我已經試圖改變arch

    1熱度

    1回答

    我正在嘗試從.csv文件讀取。下面有兩個功能,一個用於書寫,另一個用於閱讀。 該文件包含一個簡單的表: date,first,second 1 a one 2 b two 3 c three 4 c four 出於某種原因,聲明while(file_stream.read(&c,1));不讀任何東西。它停在第一個角色,我爲什麼傻眼了。任何線索? #include <io

    5熱度

    1回答

    我從這裏運行MWE: http://www.cplusplus.com/reference/ios/ios/exceptions/ 在我的機器上它沒有發現異常。這裏是我的代碼 #include <iostream> #include <fstream> int main() { std::ifstream file; file.exceptions(std::ifstr

    0熱度

    1回答

    我試圖讀取一個文件,其中包含到達時間和每個行中22個進程的突發時間。我試圖將這些值存儲到結構數組中每次進程得到一個CPU週期時,我都可以更新它們。儘管讀取操作並不成功,但請幫助我弄清楚缺少的內容。該文件是一個文本文件,如下所示: 30 0.78 \ n 54 17.28 \ n 97 32.82 \ n 。 。 。 。 #include<iostream> #include<fstream>

    2熱度

    1回答

    只是爲了理解如何正確讀取,如何讀取文件中的下一個文本,如果我想要讀取每行中的不同字符串。每一行可以有不同的尺寸(1號線可以有3串和2號線可以有100個字符串) 2 //Number of lines A AS BPST TRRER B AS BP 我在我的代碼是這樣的嘗試,但我不知道如何檢查程序是到底線。 ifstream fich("thefile.txt"); fich >> au

    1熱度

    2回答

    我想寫在文件中,然後從中讀取和打印結果 這裏是我的代碼 #include<iostream> #include<fstream> using namespace std; int main(int argc,char* argv[]){ int x,y; ofstream fd1(argv[1]); ifstream fd2(argv[1]); cin>>x; fd1<<x;

    -2熱度

    2回答

    我有一個問題,我的程序基本上是一個簡單的數學程序。它做了一些向量乘法和向量矩陣乘法,它工作正常,直到我嘗試從文本中讀取數據。我可以編譯該程序,但是當我嘗試執行它時,出現錯誤:「Dataname.exe不起作用」。 這是我的代碼。不考慮cins和couts #include<iostream> #include<cmath> #include<vector> #include"header.h

    -3熱度

    1回答

    我無法弄清楚如何在文本文件中添加數字。 95 56 34 -56 45 -79 當運行代碼,總只示出了第一次數的值。我怎樣才能將總數加起來? #include <iostream> #include <iomanip> #include <string> #include <fstream> using namespace std; int main() { int

    3熱度

    2回答

    我正在使用下面的一段代碼來檢查文件是否存在或使用std::ifstream。 #include <iostream> #include <fstream> int main() { if (std::ifstream("file.txt")) { std::cout << "File present\n"; } return 0; }