Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top