ifstream

    4熱度

    2回答

    我正在編寫一個程序,它從文本文件中獲取多個變量。 當程序找到EOF時, 它結束輸入數據。 int main() { int val, count = 0; ifstream fileIn; fileIn.open("num.txt"); fileIn >> val; while (fileIn) { ++count;

    1熱度

    1回答

    template <class T> void savetext(T *a, char const *b) //writes to text file inside .sln however the text file is corrupt { ofstream fout(b, ios::out); for (int i = 0; a[i] != '\0'; i++)

    -3熱度

    1回答

    我被要求計算10名學生的平均分數。 首先,我能夠從data.txt中文件看起來像這樣讀出和檢索數據: 編號名稱測試1的Test2 Test3的 1艾哈邁德58 97 83 2 Dollah 78 76 70 3拉梅什85 75 84 4 Maimunah 87 45 74 5羅伯特74 68 97 6庫馬爾77 73 45 7安順56 23 27 8平74 58 18 9 Idayu 47 98

    0熱度

    2回答

    我試圖打開C++中的文本文件,並逐行讀它,直到我找到一個特定的字符串,但該數據也被分成不同的部分... 該文本文件是這樣的: entry_one:true,true,false; entry_two:true,false,false; entry_three:false,false,false; entry_four:true,false,true; 基本上,我需要閱讀文本文件到內存中,

    0熱度

    1回答

    我有一個簡單的程序,試圖將二維數據讀入堆分配的浮點數組中。該計劃如下。 #include <iostream> #include <fstream> void read_file(std::ifstream &inFile, float **arr, unsigned m, unsigned n) { for(unsigned i = 0; i < m; ++i) {

    0熱度

    2回答

    我需要在使用ifstream加載的文件中導航。正確地說,我需要保存我以前的地方,以便在閱讀幾行後能夠返回到這個確切的地方。 我想類似的東西: ifstream baseINTING("base.txt"); streampos position1, position2, position3; position1 = baseINTING.tellg(); 後來我讀了幾行字: getlin

    1熱度

    1回答

    以下程序寫入100個字節,但不會全部讀回它們。爲什麼? #include <iostream> #include <random> #include <vector> #include <climits> #include <algorithm> #include <map> #include <fstream> #include <iomanip> int main() {

    1熱度

    1回答

    我寫尺寸3的載體,當我讀得大小爲4的矢量與上次指數爲索引的一個重複2 我的繼承人碼。 void IOManager::WriteBin(const string &filename, vector<userRank> highScorers, int rank) { ofstream fsalida(filename, ios::out | ios::binary); if

    4熱度

    1回答

    文件(SETTINGS.TXT)的端部不讀新行的文件內容進行解析: FULLSCREEN=On V_SYNC=On [no "\n" at the end of file] 萬一沒有ENTER「\ n」個輸出是: MapKey= FULLSCREEN MapValue= On MapKey= V_SYNC MapValue= Onřřřř 隨着ENTER「\ n」的文件輸出的到底是正

    4熱度

    3回答

    我從文本文件中拉出數字並用它們填充int類型的數組。 我插入值到陣列,同時通過與這些代碼行(其中,k是數字的.txt文件的量)的.txt文件循環: for (int j = 0; j < k; j++) inputFile >> tab[j]; 當數字在文本文件中小於2,147,483,647這是一個整數類型的最大尺寸一切順利。 當這個數字大於這個數字時,我假定程序溢出並且未能插入它