stringstream

    3熱度

    3回答

    所以我在C中寫了這個,所以sscanf在s中掃描,然後丟棄它,然後掃描d並存儲它。因此,如果輸入是「Hello 007」,則掃描但是丟棄Hello,並將007存儲在d中。 static void cmd_test(const char *s) { int d = maxdepth; sscanf(s, "%*s%d", &d); } 所以,我的問題是我怎麼能做同樣的事情

    4熱度

    3回答

    例如,而不是實際的代碼: stringstream ss; ss << " world!"; string hello("Hello"); // insert hello to beginning of ss ?? 感謝所有的答覆,我也發現了這個代碼,它的工作原理: ostringstream& insert(ostringstream& oss, const string& s)

    0熱度

    1回答

    我得到越來越錯誤的我碼出下面的錯誤是採取周(非常兼職)後略有改善: 1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\sstream(451) : error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declar

    0熱度

    1回答

    我有代碼將讀取整個文件到緩衝區。對於我的目的,我可以保證這樣的文件沒有結束,比如說10MB的大小...足夠小,我們不需要擔心在執行全文件讀取時出現抖動或真正的性能問題。 此外,我目前在生成的整個文件緩衝區中使用isstrstream提取一行。這工作得很好,並且允許我一次消耗一行內的底層字符串數據。 但是,我現在需要看看我是否可以保存當前的isstrstream位置,並在稍後「跳過」......即復

    4熱度

    3回答

    我有一個vector<char>的數據,我想寫入std::stringstream。 我想: my_ss.write(vector.data(), vector.size()); ...但它似乎置入任何my_ss我聲明如下: std::stringstream my_ss( std::stringstream::binary); 爲什麼寫不工作(應用程序不會崩潰並編譯0錯誤,0警告)?

    2熱度

    3回答

    我想要做的事情:讓我們假設我有一個TStringStream,它只讀取一個包含100個字符的字符串。如果我調用.ReadString(50),我將得到這個流的前50個字符,並且它的光標將被放置在位置51上。 我的問題是:我如何折騰1到50的字符這個流以一種快速而乾淨的方式?我想稍後閱讀其餘的(51至100)。 在此先感謝。

    5熱度

    6回答

    如何連接兩個stringstreams? #include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> #include <fstream> #include <sstream> #include <string> #include "types.h" int main() {

    0熱度

    2回答

    我已經writen此程序: #include <sstream> #include <math.h> #include <string> #include <vector> using namespace std; double distance(vector<double> *, vector<double> *, int); const char* distances(vecto

    0熱度

    2回答

    我想通過TCP套接字連接發送一個stringstream。問題是,Windows套接字只需要一個const char數據數組。什麼是使用套接字發送stringstream數據類型的最好和最有效的方法? char *szMessage="Hello World"; send(Socket,szMessage,strlen(szMessage),0); 我願意學習不同的套接字庫,如果Window

    1熱度

    3回答

    我有一個類的構造函數,像這樣: DotDashLogMatcher(std::stringstream const& pattern); 我叫它像這樣: std::stringstream s; DotDashLogMatcher(s << "test"); 這是一個過於簡單化的例子,但本質上是怎麼回事上。這是我得到的確切的編譯器錯誤。請注意,由於某些原因,傳入的結果對象是basic_o