iostream

    1熱度

    1回答

    給定一個C++ std::istream輸入內存流,是否可以以任何方式直接將該流中的數據寫入C文件流(FILE*),而無需先將數據寫入磁盤? 我問的原因是我有一個C接口採取FILE*,爲此我想透明地支持壓縮或未壓縮的輸入文件。 這個想法是編寫一個包裝函數,它接受輸入文件,然後使用boost::iostreams創建一個過濾流,在必要時執行解壓縮,然後將解壓縮的數據以某種方式轉發給C API。 直接

    2熱度

    4回答

    這裏是一個重載>>操作功能: std::istream& operator>>(std::istream& is, std::vector<int>& v){ string s; if (! (is >> s)) return is; ... return is; } 據我瞭解,if(! (is >> s))沒有任何意義,因爲終端或控制檯將等

    3熱度

    5回答

    這些代碼編譯沒有錯誤,但time宣告無處。 幸運的是,由於我將名稱更改爲mtime,錯誤消失了。但是錯誤的本質是什麼?什麼是time? 該程序的輸出爲1。我想知道文件iostream或其他地方是否有所謂的time。 #include <iostream> int main() { std::cout << time << std::endl; return 0; }

    1熱度

    1回答

    我正在C++的一個介紹級別課程上進行測驗,我試圖理解一個問題。在搜索了互聯網並沒有得到答案之後,我就在這裏。 Which of the following function declarations will accept either cout or a file stream object as its argument? A. void output(fstream &outFile)

    0熱度

    1回答

    我們知道,std :: setw()隻影響下一個輸出。 所以,對準什麼標準的做法 的整個操作< <表輸出用戶定義類型的: class A { int i, j; public: friend ostream& opeartor<<(ostream& out, const A& a) { return << "Data: [" << i << ", " << j

    0熱度

    1回答

    我對我與Sierra和Xcode9.0.1 我編譯克以下的Hello World代碼的MacBook Pro之後的tutorial ++沒有問題。 #include <iostream> main() { using namespace std; cout << "Hello, World!" << endl; } 但是,當我執行 cpp hello.cxx | mor

    2熱度

    3回答

    如果<<運算符超載的返回類型爲std::string,我很難理解編譯器控制錯誤的原因。你能幫我理解嗎? 波紋管是一個可重現的例子,它給出了一個巨大的錯誤。 class XY { int X__; int Y__; public: XY(int x, int y):X__(x), Y__(y){} ~XY(){} std::string ope

    0熱度

    1回答

    ,因爲我不允許使用的std :: string對我使用所謂的charstring類型爲那些情況下,我不能初始化它自己的包裝定製類的任務。 類看起來是這樣的: struct CharString { char* str; CharString() : str() {} // Initialize NULL ~CharString() { free(str); }

    0熱度

    1回答

    我有以下的C++代碼: #include <iostream> #include <string> #include <vector> #include <sstream> #include <iomanip> #include <cstring> using namespace std; int main() { istringstream inSS; s

    0熱度

    2回答

    我一直用這段代碼停留在同一個地方。最後決定在網上提問。任何幫助,將不勝感激。 我已經創建了一個結構體,我可以將數據添加到結構中,但仍不確定我是否遵循了正確的方法。當我嘗試從文本文件讀取數據時,主要問題在於。 我似乎得到一個錯誤說: 錯誤C2678:二進制「>>」:沒有運營商發現,這需要左手 數類型的「的std :: ifstream的」(或有沒有可接受的轉化率) 結構體: struct bankD