I do not believe that there is a way to ask NetBeans to connect the input to your program (this functionality is processed by your shell). If you want to test or debug your program in the IDE, the best way is to let it accept the file name as a parameter or to backtrack from standard input if no file name is specified. You can then configure the project launch configuration and provide a test file name as an argument.
Note that if you try to use "<file" in your startup configuration, it will simply be passed directly to your program because the shell does not intercept it.
[Edit] I found a way, although it is a little weak.
NetBeans (at least on my Mac) runs C ++ programs through a script called dorun.sh, which is located in the .netbeans folder in my home directory. It includes a line near the end like this:
"$ pgm" "$ @"
Quotation marks exclude any use of the <operator in your project properties so that you can remove quotes (and accept the consequences) or include <between them:
"$ pgm" <"$ @"
and just specify the file name as an argument.
If you do not know where to find the arguments, in the project properties, outside the file menu.
If you use NetBeans on Windows, I'm not sure what kind of script it is (if any) that it uses to run your program. Also note that this does not work if you use the output window instead of the external terminal (this parameter is in the same window).
[Edit] This is also not useful when trying to debug your program ... perhaps it is best to change the code to deal with reading from a file or stdin.
source share