Compile C++ using cmd

I can compile following code using "cl A.cpp" but i want to compile with an input file A.in and generate output file A.out.. is there any why to do that from cmd....

A.cpp
1
2
3
4
5
6
7
8
9
10
#include<stdio.h>

int main(){
	int n;
	while( scanf("%d", &n) ){
		if( !n )break;
		printf("%d\n", n);
	}
	return 0;
}


A.in
1
2
3
4
5
1
2
3
4
5
Are you wanting to run the app after it is compiled using file A.in as input and file A.out as output?
If so, then after it is compiled into A.exe, run it in the CMD window like this
A < A.in > A.out

Note: A.in is going to need to be editied so that it has an extra Blank line at the end of it in order for your program to stop instead of just sitting there.
Topic archived. No new replies allowed.