Skip to content

Instantly share code, notes, and snippets.

@thabetx thabetx/files.cpp
Created Apr 6, 2017

Embed
What would you like to do?
input and output using files
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
// use in.txt as the input stream
freopen("in.txt", "r", stdin);
// use out.txt as the output stream
freopen("out.txt", "w", stdout);
// make sure that those files are in the same directory of the cpp file
// you can now cin from the input file and cout to the output file
int x;
cin>>x; // wil read an integer from the input file
cout<<x; // will write x to the output file
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.