Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- int main()
- {
- std::ofstream outf;
- std::ofstream outfT;
- outfT.open("textFile.txt");
- outf.open("binaryFile.dat", std::ios::binary);
- int outVal{ 255 };
- for (int i{ 1 }; i < 10; ++i)
- {
- outfT << outVal << '\n';
- outf.write((char*)(&outVal), sizeof(int));
- ++outVal;
- }
- outf.close();
- outfT.close();
- std::ifstream inf;
- inf.open("binaryFile.dat", std::ios::binary);
- int val{ 1 };
- for (int i{ 1 }; i < 10; ++i)
- {
- inf.read((char*)(&val), sizeof(int));
- std::cout << val << '\n';
- }
- inf.close();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement