Created
April 6, 2017 17:57
-
-
Save thabetx/fa8b6739cfe95e7387ed3db7a64f2e43 to your computer and use it in GitHub Desktop.
input and output using files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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