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条)

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献