我有一个小问题从c ++传递一个字符串到gnuplot我可以很容易地传递整数,但是当我尝试一个字符串(用户定义为" title"在代码的前面):
fprintf(gnuplotPipe, "set title %s\n", title);
我收到错误:
error: cannot pass objects of non-trivially-copyable type ‘std::string {aka class std::basic_string<char>}’ through ‘...’
所以我尝试使用:
fprintf(gnuplotPipe, "set title %s\n", title.c_str());
和实际编译的代码,但是当我运行它时,我收到了Gnuplot的错误:
line 0: undefined variable: h
其中&#34; h&#34;只是由#34; title&#34;。
定义的测试刺痛有没有人对如何传递这个有什么想法?
提前致谢!
答案 0 :(得分:1)
您必须将标题放在引号中:
protected function addToTextArea(array:Array):void
{
textArea.text = "Array Elements are:";
for(var k:int = 0; k < array.length; k=k+1)
{
textArea.text = textArea.text +"\n"+ array[k];
}
}