这是我的代码:
str col2;
mysql_real_escape_string(con, col2, col, strlen(col));
quote_vs[i2] = malloc(strlen(col2) + 2 + 1);
sprintf(quote_vs[i2], "'%s'", col2);
不知道col2的长度,如何分配内存
最佳答案
我找到了解决方案:mysql文档说:
You must allocate the to buffer to be at least length*2+1 bytes long.
关于mysql - 如何在 mysql_real_escape_string 中为 *to 正确分配内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34792846/