ifstream

    0熱度

    3回答

    我想讓行標記//此行應該打印做它的事情,這是打印「同義詞」和「反義詞」之間的int值。 這是文本文件: dictionary.txt 1 cute 2 hello 3 ugly 4 easy 5 difficult 6 tired 7 beautiful synonyms 1 7 7 1 antonyms 1 3 3 1 7 4 5 5 4 7 3 #i

    -2熱度

    1回答

    我想消除我在下面的vector<int> synsAux上遇到的垃圾。它應該打印: 1 7 7 1 我的第一和第三位,爲什麼之前獲得一個額外的2?這是2的空格或什麼的ascii值?我如何避免閱讀? 這是運行程序所需要的字典文件: dictionary.txt 1 cute 2 hello 3 ugly 4 easy 5 difficult 6 tired 7 beautif

    7熱度

    5回答

    我一直在這裏關於ifstream的問題,所以我仍然無法閱讀簡單的文本文件。我與Visual Studio 2008年的工作 這裏是我的代碼: // CPPFileIO.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <fstream> #include <

    3熱度

    1回答

    說我這樣做(一個人爲的例子): #include <iostream> #include <fstream> using namespace std; int main(int argc, char* argv[]) { ifstream ifs(argv[1]); char ch; while(ifs.read(&ch, 1)) { cou

    1熱度

    3回答

    當出現單詞「同義詞」時,我想停止閱讀我的文本輸入文件。我正在使用ifstream,我不知道如何打破循環。我嘗試使用stringstream「同義詞」,但它結束了我的bst。如果您想避免打字,我會在下面列出完整的項目文件。 重要組成部分: for(;;) /*here, I wanna break the cycle when it reads "synonyms"*/ {

    0熱度

    3回答

    我知道關於std :: ifstream :: open()有一些問題,但答案並沒有解決我的問題。他們大多數都是特定於Win32的,我使用的是SDL,沒有觸及任何特定於操作系統的功能(......沒有包含到SDL中)。 問題是:std :: ifstream :: open()似乎不工作了,因爲我已經從Dev-C++切換到Code :: Blocks(我一直在使用相同的MinGW-GCC返回與兩者

    1熱度

    1回答

    在VS 2005,我有一些代碼,看起來像這樣: ifs.open("foo"); while (!ifs.eof()) { ifs.read(&bar,sizeof(bar)); loc = ifs.tellg(); loc += bar.dwHeaderSize; // four byte boundary padding if ((loc

    6熱度

    5回答

    我目前正在編寫一個模擬退火代碼來解決旅行商問題,並遇到了存儲和使用從txt文件中讀取數據的困難。文件中的每一行&列表示各城市,存儲爲15×15矩陣的兩個不同城市之間的距離: 0.0 5.0 5.0 6.0 7.0 2.0 5.0 2.0 1.0 5.0 5.0 1.0 2.0 7.1 5.0 5.0 0.0 5.0 5.0 5.0 2.0 5.0 1.0 5.0 6.0 6.0 6.0 6.0

    8熱度

    3回答

    我想從二進制文件中讀取無符號字節。 所以我寫了下面的代碼。 #include <iostream> #include <fstream> #include <vector> #include <istream> std::string filename("file"); size_t bytesAvailable = 128; size_t toRead = 128; std::