奇怪的 gcc 错误杂散/丢失终止” C语言中的字符
我收到以下错误:
error: missing terminating " character
并且
error: stray `\' in program
在这行 C 代码中:
system("sqlite3 -html /home/user/.rtcom-eventlogger/el.db \"SELECT service_id, event_type_id,free_text, remote_uid FROM Events WHERE remote_uid=\'%d\' ORDER BY start_time DESC;\" > lol.html", nr);
“nr”是一个整数变量。
我已经讨论过很多次了,但完全找不到解决方案。
编辑:如果我没有说清楚,错误是使用 gcc 编译时的输出。
I get the following errors:
error: missing terminating " character
and
error: stray `\' in program
In this line of C code:
system("sqlite3 -html /home/user/.rtcom-eventlogger/el.db \"SELECT service_id, event_type_id,free_text, remote_uid FROM Events WHERE remote_uid=\'%d\' ORDER BY start_time DESC;\" > lol.html", nr);
"nr" is a integer variable.
I have gone over this so many times but are totally stuck of finding a solution.
EDIT: The errors is the ouput while compiling with gcc if I didn't make that clear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 C 中的双引号字符串中,我认为
\'
没有任何意义。看起来您的反斜杠是为了保护 shell 中的单引号,这意味着它们应该在字符串中使用双反斜杠:remote_uid=\\'%d\\'< /代码>。
Within a double-quoted string in C, I don't think that
\'
has any meaning. It looks like your backslashing there is meant to protect the single quotes in the shell, which means they should be double-backslashed within the string:remote_uid=\\'%d\\'
.好吧,您不需要转义字符串内的单引号(例如
\'
应该只是'
),但我不确定这会导致你看到的错误。Well, you don't need to escape the single quotes inside the string (e.g.
\'
should just be'
), but I'm not sure that that would cause the error you're seeing.我遇到了同样的问题,试图做基本相同的事情。
我的问题是我使用 WinZip 来解压缩源代码。使用7z后效果很好。
I had the same problem, trying to do basically the same thing.
My problem was that I used WinZip to decompress the source. After using 7z it worked fine.
就我而言,我有一个带有转义“的外部定义变量,如下所示:
它被嵌入到如下代码中:
In my case I had an external define variable with escaped ", like this:
It was transcluded into code like this: