【问题标题】:How to properly alloc memory for *to in mysql_real_escape_string如何在 mysql_real_escape_string 中为 *to 正确分配内存
【发布时间】:2016-01-14 15:07:28
【问题描述】:

这是我的代码:

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 c linux


    【解决方案1】:

    我找到了解决办法:mysql文档说:

    You must allocate the to buffer to be at least length*2+1 bytes long.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-20
      • 1970-01-01
      相关资源
      最近更新 更多