What does this program do?

Advertisement

#include <iostream>
#include <fstream>
using namespace std;

int main(){
ifstream file1(“text1.txt”, ios::binary);
ofstream file2(“text2.txt”, ios::binary);
file2 << file1.rdbuf();
}

  • It renames text1.txt to text2.txt.
  • It makes a directory called text2.txt and moves text1.txt there.
  • It copies the contents of text1.txt into text2.txt – i.e., it makes a copy of text1.txt, named text2.txt.
  • It appends the contents of text1.txt into text2.txt – i.e., replaces the contents of text2.txt by the concatenation of text2.txt and text1.txt.
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Leave a Comment

Share via
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Send this to a friend