如何在运行CLion Debugger时将文件作为参数

时间:2016-03-12 04:04:40

标签: cmake clion

我有一个用getline(cin,line)执行操作的c ++程序。当我使用g ++编译.c文件时,我通常只运行

g++ lr.cc -o lr
./lr < text

text是一个文件。

但是我收到错误并希望调试代码中的错误生成位置(它出现terminate called after throwing an instance of 'char const*' Aborted (core dumped)错误)但我似乎无法获得CLion编译代码并使文本文件成为&#34;参数&#34;。

我尝试使用完整路径< test编辑< /path/to/text/的参数,并将文件添加到CMakeLists.txt的set(SOURCE_FILES)

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

原来他们不支持它(但是?)。使用

std::ifstream in("/path/to/file/to/read");
std::cin.rdbuf(in.rdbuf());

在我的函数开头读取cin并启动调试器