STDIN在Netbeans [英] STDIN in Netbeans

查看:212
本文介绍了STDIN在Netbeans的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

有人知道..如何读取文件到Netbeans的STDIN。

我在Netbeans有一个问题我的程序。该程序的工作原理如下:

Hi
Does someone know.. how to read files to STDIN in Netbeans.
I have a Problem my Program in Netbeans. The Program works like this :

./myprog < in.txt

这是一个C ++项目。
任何想法?

It's a C++ Project. Any Ideas ?

编辑:我有Proglems设置netbeans。在哪里可以说:阅读/使用这个文件?
在控制台上它只是工作正常!

Edit : I have Proglems with setting up netbeans . where can i say : READ/USE THIS FILE ? On the Console it just works fine !

推荐答案

我不相信有一种方法要求NetBeans管道输入到您的程序(该功能由您的shell处理)。如果要在IDE中测试或调试程序,最好的方法是允许它将文件名作为参数,或者如果没有指定文件名,则返回标准输入。

I don't believe there's a way to ask NetBeans to pipe input to your program (that functionality is handled by your shell). If you want to test or debug your program in the IDE, the best way is to allow it to take a filename as a parameter, or fall back on standard input if no filename is given. Then you can adjust your project run configuration and supply the test filename as an argument.

请注意,如果您尝试在运行配置中使用< file,那么您可以调整您的项目运行配置并提供测试文件名作为参数。因为没有shell拦截它。

Note that if you try to use "< file" in the run configuration, that will simply be passed directly to your program, because there is no shell intercepting it.

我找到一种方法,虽然有点弱。

I found a way, though it's a bit weak.

NetBeans(至少在我的Mac上)通过名为dorun.sh的脚本运行C ++程序,该脚本在我的主目录下的.netbeans文件夹下。它包括一个接近结束的行,像这样:

NetBeans (at least on my Mac) runs C++ programs via a script called dorun.sh, which is under the .netbeans folder in my home directory. It includes a line near the end like this:

$ pgm$ @

逃避任何使用运算符,因此您可以删除引号(并接受后果),或者包含<之间:

The quotes escape any use of the < operator in your project properties, so you could remove the quotes (and accept the consequences), or include a < between them:

$ pgm< $ @

"$pgm" < "$@"

,只需将文件名作为参数。

and simply include the filename as an argument.

如果你在Windows上使用NetBeans,我不知道是什么类型的脚本如果有的话)它用来启动你的程序。另请注意,如果使用输出窗口而不是外部终端(此设置位于同一个窗口中),则此操作不起作用。

If you're using NetBeans on Windows, I'm not sure what kind of script (if any) it uses to launch your program. Also note that this doesn't work if you use the output window instead of an external terminal (this setting is in the same window).

也没有好的,当试图调试你的程序...可能最好只是修改你的代码来处理从文件或stdin读取。

This is also no good when trying to debug your program... probably best just to amend your code to deal with reading from either a file or stdin.

这篇关于STDIN在Netbeans的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆