tags:

views:

350

answers:

2

I'm using NetBeans to develop some simple applications to solve puzzles. Upon launching one of these simple console applications, I'd like to get the input from a simple text file that I put together.

I recall mention of redirecting standard input and output. I looked up the syntax but I'm not sure on the proper way to tell NetBeans (or any IDE for that matter) to accept this file as input...

How might I do this from netbeans?

It works perfectly from my Cygwin window by executing:

./myProg.exe < input.txt

A couple of notes:

  • I'm developing in C
  • My compiler is GCC on Cygwin
A: 

I never used Netbeans, but I found this:

http://stackoverflow.com/questions/959338/stdin-in-netbeans

Hope that helps.

Mike Mu
I'm not sure that posting's answer is right, but that is the most information I've seen on the subject. You get the green checkmark for now... unless someone can tell me how to do it directly. Thanks for finding that. (I swear I searched!)
Frank V
A: 

I did find a way to sort of accomplish this. I wanted to share this in case anyone finds this question with the need to do something similar. Put the following towards the begining of your main function. Note that this is C; I don't know if this will work in C++ but it might.

freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);

I found this at: http://www.codechef.com/help/#hc_inout

Frank V