调试时输入CLion标准输入 [英] CLion standard input while debugging

查看:557
本文介绍了调试时输入CLion标准输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做的基本上是:



。/myProgram< myData.txt



我正在使用CLion IDE进行调试。我只是找不到这样做的选项。



A 类似问题-但产品特定于MSVS

解决方案

我遇到了同样的问题,似乎CLion尚未处理标准输入。



我在运行程序之前通过更改输入流来解决此问题。 / p>

例如,如果要在stdin中输入文件流,可以在main中编写:

  std :: ifstream in( ABSOLUTE_PATH_TO_YOUR_FILE); 
std :: cin.rdbuf(in.rdbuf());

然后,您可以找到一种在需要时切换此流更改的方法。请注意,对于文件,您将需要提供绝对路径,因为该应用程序是从与当前目录不同的目录运行的。



我希望这可以有所帮助,直到CLion提供真实的目录为止。解决方案。


What I'm trying to do is basically:

./myProgram < myData.txt

While I'm debugging with CLion IDE. I just can't find the option to do so.

A similar question - but product-specific to MSVS

解决方案

I had the same problem and it seems that CLion is not handling standard inputs yet.

I got around this problem by changing the input stream before running my program.

As an example if you want to input a file stream inside your stdin you can write in your main:

std::ifstream in("ABSOLUTE_PATH_TO_YOUR_FILE");
std::cin.rdbuf(in.rdbuf());

Then you can find a way to toggle this stream change when you want. Note that for files you will need to provide absolute path since the application is run from a different directory than the current one.

I hope this can help until CLion provides a real solution.

这篇关于调试时输入CLion标准输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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