stringstream

    1熱度

    1回答

    我有一個複雜的對象,我希望能夠通過<<運算符將其傳遞到std::ostringstream,就像字符串或int。我想給ostringstream對象的唯一id(int)和/或name(string)。是否有我能在我的課程中實施的操作員或方法以使其工作?

    1熱度

    3回答

    我不知道爲什麼這是錯誤的,但我只是想添加一些「類似」到endl,以便我可以拋出什麼在ostringstream我們的調試器。我有以下幾點: class debug_stream_info { public: debug_stream_info(int errorLine, char *errorFile, int level) :m_errorLine(errorLine

    1熱度

    1回答

    我在串流問題上有些麻煩;每當我嘗試對非空字符串使用in-operator(< <)時,我會在運行程序時打印一張內存映射。下面的代碼: for(int i=1 ; i<djikstra_result[0] ; i++) { cout << "DEBUG 5:10 - Round " << i << endl; if(i==djikstra_result[0]-1) {

    6熱度

    2回答

    我學習C++並得到了項目發送一個帕斯卡的三角形輸出(在n行計算後)。,得到這樣的輸出,存儲在字符串流「緩衝區」 1 1 1 1 2 1 1 3 3 1 但我想是相當 1 1 1 1 2 1 1 3 3 1 我的想法是:計算最後一行和當前行的長度(我知道,最後一個是最長)的差異。然後使用空格填充每行(線長差的一半)。 現在我的問題是: 我沒有得到如何函數getli

    0熱度

    1回答

    我的代碼如下 std::ostringstream tmpstr, tmpstr2; for(/* something */) { //writting inside tmpstr } tmpstr2 << tmpstr.rdbuf(); cout << "assigned to tmpstr2"; out <<tmpstr2.str().c_str() ; // Wher

    0熱度

    1回答

    是什麼以下 stringstream a; stringstream b; a << "hi"; b << "there"; a << " " << b.rdbuf();或a << " " << b.str();或a << " " << b.str().c_str(); 我一直在使用rdbuf()之間的差異。我也注意到,在C++參考說爲stringstream::rdbuf: 注意,對於

    1熱度

    1回答

    我有例如 string s = " abc edef"; 創建istringstream這個字符串。 有沒有辦法從getline得到只有​​和"edef"? Beacouse現在我得到空對之間的空字符串:/

    3熱度

    1回答

    使用Delphi XE, 我需要將TStringStream解析爲由字符串分隔的字符串。 在一種情況下,定界符字符串是[eol]。 流使用indy IdHttp從Web服務器加載。 然後,我需要解析出流中的字符串,並用字符串「[eol]」分隔它們。 作爲一個例子,字符串流可能包含: 「12345 [EOL]這是]東西[EOL]和[這是什麼[EOL]等[etcetc [EOL]」 應解析爲: 「12

    0熱度

    2回答

    我遇到了std :: cout,std :: stringstream和std :: string.c_str()的問題。主要看起來有些東西被某處緩衝區所困住,我不知道如何解決這個問題。 如果你不喜歡的StackOverflow閱讀代碼,這裏有相關鏈接到我的github: 的TLString class的Test class,並且the unit test - 你可以跳到這裏我說明我的更簡潔的問題

    10熱度

    4回答

    我不知道我正在寫是有道理的,但我remeber我看到了一個功能ivoked這樣的: my_func(ss << "text" << hex << 33); 這可能嗎?