You may get away with the pipe operators. If you type "dir > dir.txt" into the cmd line, it will re-direct, or Pipe the output to the file instead of the standard output. Similarly, you can use the other symbol '<', to Pipe input from a file, instead of the keyboard.
Here, here's a quick sample I knocked-up during the ad-break.
1. C source
#include <cstdio>
int main()
{
    int numPairs, num1, num2, result;
    int curPairIndex;
    printf("Enter number of pairs to add: ");
    scanf("%d", &numPairs);
    printf("\n");
    for (curPairIndex=0; curPairIndex<numPairs; curPairIndex++)
    {
        scanf("%d %d", &num1, &num2);
        printf("%02d. %d + %d = %d\n", curPairIndex, num1, num2, num1+num2);
    }
    return 0;
}
2. sampleInput.txt
3
3   4
10  20
100 1000
3. Sample cmd-line command
001-forumSample < sampleInput.txt > sampleOutput.txt
4. sampleOutput.txt
Enter number of pairs to add: 
00. 3 + 4 = 7
01. 10 + 20 = 30
02. 100 + 1000 = 1100