Consider the following code:
char *myContent = "content";
int size = snprintf(NULL, 0, "INSERT INTO myTable (col1) VALUES('%s')",myContent);
char *query = malloc(size+2);
snprintf(query, size, "INSERT INTO myTable (col1) VALUES('%s')",myContent);
Now I have the problem that the last bracket is truncated:
(gdb) print query
$2 = 0x616080 "INSERT INTO myTable (col1) VALUES('content'"
This is not a valid SQL statement, so have you an idea what the reason could be that the last bracket is missing?
snprintfreturns:But the size argument is:
So you should: