gpt4 book ai didi

c++ - 创建管道并从 C++ 写入 gnuplot 终端

转载 作者:太空宇宙 更新时间:2023-11-04 14:24:23 25 4
gpt4 key购买 nike

我正在尝试从 C++ 调用 gnuplot。我正在为 Windows 和 VS2005 c++ 使用 wgnuplot。

以下语句有效,因为它打开了 gnuplot 终端

FILE *p = _popen("wgnuplot -persist","w");

但是我不能在那里写任何东西。即使在运行以下代码后,我的终端仍然是空白的。

fprintf(p, "set terminal x11 enhanced\n"); //set appropriate output terminal for the plot 
fprintf(p, "set xlabel 'N'\n");//set xlabel
fprintf(p, "set ylabel 'error'\n");//set ylabel

能否请您告诉我可能是什么问题,即为什么终端是空白的并且 fprintf() 似乎不起作用?

谢谢,

鲍里斯

最佳答案

检查 FILE 指针是否不为 NULL:

if(!p)
// _popen() has failed...

关于c++ - 创建管道并从 C++ 写入 gnuplot 终端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5251834/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com