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

#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

Maybe use command line arguments, read a file using it?

LINK

a <a.in >a.out At the command line,
< will input a file as if it was from the keyboard
> will take the stuff that goes to the screen and put it a file instead

Thank you, WaltP. It works....

Thank you, WaltP. It works....

Yeah, I know... :icon_wink: :icon_mrgreen:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.