getline

    0熱度

    2回答

    我想讀取names.txt文件中的數據,並輸出每個人的全名和理想體重。使用循環從文件中讀取每個人的姓名,英尺和英寸。 讀取文件: Tom Atto 6 3 Eaton Wright 5 5 Cary Oki 5 11 Omar Ahmed 5 9 我使用這下面的代碼: string name; int feet, extraInches, idealWeight; ifstream inFil

    -1熱度

    2回答

    程序應該將輸入數字的字符串和數字分隔符作爲輸入,並將4個單詞輸出到單獨的行中。 例 Please enter a digit infused string to explode: You7only7live7once Please enter the digit delimiter: 7 The 1st word is: You The 2nd word is: only The 3rd

    -1熱度

    3回答

    我想讀取一行字符,但只輸出第二個和第四個字符。我無法忽視第一個字符。我必須使用get,peek和ignore函數。這是我的代碼! #include<iostream> #include<iomanip> using namespace std; int main() { char char2, char4; cout << "Enter an arbitary line. "<

    -2熱度

    1回答

    不好意思問,但我一直在到處找找到一種方法,從該組字符串的提取整數: {(1,2),(1,5),(2,1),(2,3),(3,2),(3,4),(4,3),(4,5),(5,1),(5,4)} 我並不真的需要完成家庭作業,如果你能聯繫我到例如,我會感激。 感謝您的高級。

    0熱度

    1回答

    爲什麼要在控制檯的第二行輸入內容? int main() { string s; while (true) { cout << "Input: "; char a = getline(cin, s).get(); cout << a << endl; } return 0; }

    -1熱度

    1回答

    第二次不起作用。我試圖filestr.clear()/ flush()和其他人沒有結果。如果我在第一時間評論一切正常,但我需要對象的數量。有人請幫助 while (std::getline(filestr, line)) { if (line.find("<rect") != std::string::npos) count_rect++; } rect =

    0熱度

    1回答

    我的程序使用ifstream()和getline()來解析一個文本文件到兩個向量深的對象中。即矢量內的矢量。一旦文本文件加載完成,內部向量包含超過250000個字符串對象。 這是痛苦的緩慢。有沒有比使用ifstream()和getline()更有效的STD替代方法? 感謝 UPDATE: #include <iostream> #include <fstream> #include <stri

    -3熱度

    2回答

    林試圖讀取與在上述格式輸入的文本文件。林能看懂每一行與此代碼: FILE *file = fopen(argv[1], "r"); ... char * line = NULL; size_t len = 0; ssize_t read; while ((read = getline(&line, &len, file)) != -1) 使「線」是等於文件,如果我輸出的每個線時所讀

    0熱度

    1回答

    我一直在尋找幾個小時,但尚未遇到我的問題。我從一個文件中的第一行中讀取數據是電影的數量後,該線將是電影片名,導演等 例子: 2 Friday Night Lights: Upcoming;Bond, James;2061;128;93000000;871530324 Friday Night Lights: Upcoming;Bond, James;2061;128;93000000;8715

    1熱度

    3回答

    我有了很多行的文本文件,一個例子是 約翰:學生:業務 可能:講師:數學 鮑勃:學生:數學 我如何拆分起來,並將它們存儲在不同的載體如: 向量1:約翰,可以,鮑勃 vector2:學生,講師,學生 的Vector3:商務,數學,數學 我當前的代碼是: ifstream readDetails(argv[1]); while (getline (readEvents, line, ':')){