954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Compile C++ Code

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
fkrafi
Newbie Poster
2 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

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

LINK

myk45
Posting Whiz
319 posts since Sep 2010
Reputation Points: 57
Solved Threads: 40
 

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

WaltP
Posting Sage w/ dash of thyme
Moderator
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 

Thank you, WaltP. It works....

fkrafi
Newbie Poster
2 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 
Thank you, WaltP. It works....


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

WaltP
Posting Sage w/ dash of thyme
Moderator
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: