奇怪的 gcc 错误杂散/丢失终止” C语言中的字符

发布于 2024-09-03 05:45:50 字数 482 浏览 11 评论 0原文

我收到以下错误:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

枕梦 2024-09-10 05:45:50

在 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\\'.

谎言月老 2024-09-10 05:45:50

好吧,您不需要转义字符串内的单引号(例如 \' 应该只是 '),但我不确定这会导致你看到的错误。

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.

山有枢 2024-09-10 05:45:50

我遇到了同样的问题,试图做基本相同的事情。

我的问题是我使用 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.

愿与i 2024-09-10 05:45:50

就我而言,我有一个带有转义“的外部定义变量,如下所示:

#define DEFINE \"string\"

它被嵌入到如下代码中:

cout << DEFINE; // source code

cout << \"string\"; // source code during compilation

In my case I had an external define variable with escaped ", like this:

#define DEFINE \"string\"

It was transcluded into code like this:

cout << DEFINE; // source code

cout << \"string\"; // source code during compilation
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文