DIFF.BLOG
New
Following
Discover
Jobs
More
Suggest a blog
Upvotes plugin
Report bug
Contact
About
Sign up  
[C++]读写二进制文件和文本文件
1
·
王爱国
·
April 20, 2018, 9:45 a.m.
Summary
ifstream,ofstream读写二进制文件 #include <iostream> #include <fstream> using namespace std; int main(int argc, char** argv) { int a[5] = {1,2,3,4,5}; int b[5]; ofstream ouF; ouF.open("./me.dat", std::ofstream::binary); ouF.write(reinterpret_cast<const char*>(a), sizeof(int)*5); ouF.close(); ifstream inF; inF.open("./me.dat", std::ifstream::binary); inF.read(reinterpret_cast<char*>(b), sizeof(int)*5); inF.close(); for (int i = 0; i < 5; i++) { cout << b[i] << endl; } return 0; } 参考: https://blog.csdn.n...
Read full post on dawnarc.com →
Submit
AUTHOR
RECENT POSTS FROM THE AUTHOR