dongqiangou5724 2017-04-11 13:10
浏览 121
已采纳

C ++是否可以将包含换行符的文本传递给C ++程序?

I am calling a C++ program via PHP, using the system() function:

$use = '"' . $_POST['source'] . '"';
system("Subject " . $use);

where $use stores some text that might contain line breaks and that gets itself passed to the PHP program using the $_POST variable. If I pass this variable to the C++ program and the contained text has line breaks, then only the first line gets passed to the program. I tried to avoid this by using the two quotation marks, but this doesn't work. So if the input is for example

word 1  
word 2

then only word 1 is passed to the C++ program. Conversely, if the input is of the form

word 1 word 2

then of course everything works fine.

How can I solve this if there is a solution at all?

  • 写回答

2条回答 默认 最新

  • dongtaochan0777 2017-04-11 13:26
    关注

    You need to escape $use for the command line

    system("Subject " . escapeshellarg($use))
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题