istringstream

    1熱度

    1回答

    最近我一直在爲我的決賽寫作片段。其中一個常見任務是將一個字符串(std :: string)分解爲單詞。在某些情況下,這些字符串可以包含整數。 我寫了一個片段: #include <sstream> #include <iostream> #include <vector> using namespace std; int main(void) { string str="23 00

    1熱度

    1回答

    我有如下功能: void process (std::string str) { std::istringstream istream(str); std::string line; std::string specialStr("; -------- Special --------------------\r"); // win //std::stri

    1熱度

    2回答

    我對編碼相當陌生,我希望有人能幫助我嗎?我試圖讀取一行空格分隔的整數,並將它們解析爲(最終到一個鏈表中)一個向量。 所以一旦我有一個整數向量,有STL向量的迭代器,但我怎麼能遍歷鏈接列表中不在STL中的節點? #include <cstdlib> #include <iostream> #include <string> #include <sstream> #include <vecto

    0熱度

    1回答

    我有了數百萬行的txt文件,每行有3輛彩車,我讀它使用下面的代碼: ifstream file(path) float x,y,z; while(!file.eof()) file >> x >> y >> z; 和我的作品完美。 現在我想嘗試使用Boost映射文件做同樣的事情,所以我下面 string filename = "C:\\myfile.txt"; file_map

    0熱度

    2回答

    我需要從流 - istringstream(在main())中打印一些數據。 例如: void Add (istream & is) { string name; string surname; int data; while (//something) { // Here I need parse stream co

    0熱度

    2回答

    誰能解釋一下下面的代碼是如何工作的,並不會不應用程序崩潰? int main() { char *tempStr = new char[5]; tempStr[0] = '\0'; string stemp = "helloworld"; stringstream sstream; sstream.str(stemp); cout <<

    0熱度

    3回答

    人!我一直在努力解決這個問題一段時間,到目前爲止我還沒有找到任何解決方案。 在下面的代碼中,我用一個數字初始化一個字符串。然後,我使用std :: istringstream將測試字符串內容加載到double中。然後我把這兩個變量都考慮進去 #include <string> #include <sstream> #include <iostream> std::istringstream

    0熱度

    2回答

    我有這樣一段代碼: if(flag == 0) { // converting string value to integer istringstream(temp) >> value ; value = (int) value ; // value is a } 我不知道如果我使用istringstream運營權。我想將變量「值」轉換爲整數。 Compiler error : I

    2熱度

    1回答

    我有這樣的對象: istringstream ob_stream; 我需要這個對象轉換爲字符串和字符數組工作。怎麼做?

    0熱度

    1回答

    的我有以下的代碼: #include <sstream> #include <iostream> using namespace std; int main() { string inp, s; istringstream iss; do { getline (cin, inp); iss(inp); int a