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
I don't think what you're trying to do has anything to do with compilation... it rather sounds like you want to read/ write from/to a file, correct?

In that case (since you're using C), you'd have to use the functions
fopen, fclose, fscanf, fprintf, fread, fwrite etc from the stdio.h header. You can read about those on this site, just enter them into the search bar above.
I got the command, it is

1
2
cl A.cpp
A < A.in > A.out
Topic archived. No new replies allowed.