开发者

Weird gcc error stray/missing terminating " character in C

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开发者_JAVA技巧 errors is the ouput while compiling with gcc if I didn't make that clear.


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.


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:

#define DEFINE \"string\"

It was transcluded into code like this:

cout << DEFINE; // source code

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜