StudyLover
  • Home
  • Study Zone
  • Profiles
  • Contact us
  • Sign in
StudyLover 22. Program to read and write binary data in a file.
Download
  1. C++ Programs list
21. Program to implement function templates. : 23. Program to read content from one file and write it to another file.
C++ Programs list

1.      Program to read and write binary data in a file.

  1. #include <iostream.h>

  2. #include <fstream.h>

  3. #include<conio.h>

  4. int main() {

  5.     ofstream fout("data.bin", ios::binary);

  6.     char num1[100];

  7.     cout << "Enter Content: "<<endl;

  8.     cin >> num1;

  9.     cout << "Writing Content in file 'data.bin'";

  10.     fout.write((char*)&num1, sizeof(num1));

  11.     fout.close();

  12.     ifstream fin("data.bin", ios::binary);

  13.     char n1[100], n2;

  14.     fin.read((char*)&n1, sizeof(n1));

  15.     fin.close();

  16.     cout << "Content of file 'data.bin' is: " << n1 <<  endl;

  17.     getch();

  18.     return 0;

  19. }

  20.  

21. Program to implement function templates. 23. Program to read content from one file and write it to another file.
Our Products & Services
  • Home
Connect with us
  • Contact us
  • +91 82955 87844
  • Rk6yadav@gmail.com

StudyLover - About us

The Best knowledge for Best people.

Copyright © StudyLover
Powered by Odoo - Create a free website