使用popen在c ++中与gnuplot连接?

时间:2014-11-19 00:56:19

标签: c++

我的c ++程序中有一个奇怪的问题。我使用popen()打开gnuplot并使用fprintf(gnuplot,"command line")与之通信。我尝试使用此gnuplot命令时发生的问题:set output "nameofthefile.ps"是程序中的语句变为分离:

fprintf(gnuplot,"set output "`plot.ps`" \n");

plot.ps离开了" ",当我编译它时说:

main.cpp:54:31: error: expected ‘)’ before ‘plot’
  fprintf(gnuplot,"set output "plot.ps" \n");

我该如何解决这个问题?!

1 个答案:

答案 0 :(得分:3)

你没有正确地逃脱你的弦乐。尝试:

fprintf(gnuplot,"set output \"plot.ps\" \n");

你不能在自己的字符串中有"个字符串,或者它会结束字符串。