istringstream

    4熱度

    2回答

    所以,我一直在試圖找出如何等待一個C++字符串流數據(例如),但是不經常檢查,如果數據是存在的,這是相當CPU消耗。 我完全能看懂,例如,從串行設備,也沒有數據到達鎖的進程,但不幸的是我一直沒能弄清楚如何做到這一點與C++流。 我敢肯定,我失去了一些東西,因爲CIN正是這麼做的,即,等待返回鍵從istream的讀取走出,但它是如何做到的呢? 非常感謝您對這個問題的任何看法。

    0熱度

    3回答

    我試圖寫一個C++ OpenGL應用程序加載.obj文件,我使用該代碼來讀取 頂點: char buf[256]; while(!objFile.eof()) { objFile.getline(buf,256); coordinates.push_back(new std::string(buf)); } else if ((*coordinates[i])[0]=

    0熱度

    1回答

    我想下面的C代碼轉換爲C++利用istringstream困惑: void test(char *s) { int i; sscanf(s, "%*s%d", &i); } 我至今是: void test(char *s) { int i; istringstream iss(s); iss >> s >> i; } 它有錯誤出現。我對

    5熱度

    4回答

    在下面的函數中,通過查看是否可以讀取類型T以及輸入是否完全消耗之後,嘗試查看字符串s是否可以轉換爲類型T。我想 template <class T> bool can_be_converted_to(const std::string& s, T& t) { std::istringstream i(s); i>>std::boolalpha; i>>t;

    0熱度

    1回答

    我有下面的代碼,它使用strtok從txt文件接收輸入。在TXT文件中的輸入是: age, (4, years, 5, months) age, (8, years, 7, months) age, (4, years, 5, months) 我的代碼如下所示: char * point; ifstream file; file.open(file.c_str()); if(fil

    59熱度

    1回答

    我編碼在Eclipse和具有類似如下: #include <ftream> #include <iostream> void read_file(){ char buffer[1025]; std::istringstream iss(buffer); } 但是,當我嘗試建立,我得到以下錯誤:variable 'std::istringstream iss' has

    1熱度

    3回答

    我有一個涉及流的C++課程的編程任務,我試圖更好地理解爲什麼某些功能以他們的方式工作。 我正在讀取文本後面帶有空白的istringstream的輸入。爲什麼最後一個單詞在輸出中重複? istringstream is; string inputstring = "The cliched statement regarding the big brown dog and foobar or som

    0熱度

    2回答

    我需要使用字符串流從文件讀入表達式,並將表達式轉換爲另一種形式。但是我很難弄清楚如何使用Istringstream從文件中讀取行。任何人都可以幫助我的#includes和語法爲此?由於

    0熱度

    1回答

    我想在一個特徵向量文件存儲的特徵向量以下列方式爲: (標籤)(BIN):(值)(BIN ):(值)等 像: -1 5:0.015748 6:0.0472441 7:0.0393701 8:0.00787402 12:0.0314961 13:0.0944882 14:0.110236 15:0.0472441 20:0.023622 21:0.102362 22:0.110236 28:0.015

    1熱度

    1回答

    我正在研究一個允許用戶添加「部門」到學校記錄的程序。該部門存儲結構是這樣的: struct Department{ string ID; string name; }; 到新部門增加了記錄,用戶必須輸入格式如下的命令: D [5 digit department ID number] [Department name] 的[Department name]字段是延伸