我如何關閉C++中的IStream?如何關閉IStream?
1
A
回答
1
檢查這個reference。
// read a file into memory
#include <iostream>
#include <fstream>
using namespace std;
int main() {
int length;
char * buffer;
ifstream is;
is.open ("test.txt", ios::binary);
// get length of file:
is.seekg (0, ios::end);
length = is.tellg();
is.seekg (0, ios::beg);
// allocate memory:
buffer = new char [length];
// read data as a block:
is.read (buffer,length);
is.close();
cout.write (buffer,length);
delete[] buffer;
return 0;
}
0
你可以用ifstream :: close關閉文件iostreams。關閉一個istream並沒有什麼意義 - 它應該關閉shell才能啓動程序嗎?
您可以刷新一個的iostream,以確保輸出寫入
3
如果你的意思是COM IStream,只需調用IUnknown :: Release()。
相關問題
- 1. 如何關閉
- 2. 如何在關閉JasperViewer時關閉JFrame
- 3. 如何在Windows關閉時關閉FiddlerCore
- 4. 如何關閉模式關閉popovers?
- 5. istream :: ignore()如何工作?
- 6. 如何關閉IO?
- 7. 如何關閉().executeUpdate?
- 8. 如何關閉AlertDialog?
- 9. 如何關閉UIPageViewController?
- 10. 如何關閉UIKeyboardTypeNumberPad?
- 11. 如何關閉webView?
- 12. 如何關閉`runTCPServer`?
- 13. 如何關閉imagePickerController?
- 14. 如何關閉HTTPS
- 15. WPF'Toaster'Popup - 如何關閉?
- 16. 如何關閉com.sun.net.httpserver.HttpServer?
- 17. 如何關閉GIT_CURL_VERBOSE?
- 18. 如何關閉Splashscreen?
- 19. 如何關閉iframe?
- 20. 如何關閉PushViewController?
- 21. 如何關閉「periodic_call_remote」
- 22. Error.aspx - 如何關閉?
- 23. 如何關閉PopupViewController
- 24. 如何關閉Javafx?
- 25. 如何關閉Firefox?
- 26. 如何關閉PereferenceActivity
- 27. 如何關閉AlertDialog.Builder?
- 28. 如何關閉FBWebDialogs
- 29. 如何關閉CachedObservable
- 30. 如何關閉Teamcity?
調用其Release()方法。 – 2011-03-01 19:12:05
你是指'std :: istream'還是COM'IStream'?你是怎麼打開它的?這可能會確定關閉它的正確方法。 – 2011-03-01 19:15:46