Give input file

hey, i want to give input file(having alot of input files), to a program. and also to get the output file.

suppose in the following program:
1
2
3
4
5
6
7
8
9
10
11
12
#include<iostream>
#include<conio.h>

using namespace std;
int main()
{
    int x;
    cin>>x;
    cout<<x*x<<endl;
    getch();
    return 0;
}


How to do it?
Can you be a bit more specific?
ie:
- Do you want to specify the file as argument to your program?
- Do you want to prompt the user for a file name?
- Do you want to hardcode the file name?
I want it to be like the one that are in programming contests, file open by "freopen"..... Sorry, am a beginner.
Topic archived. No new replies allowed.