我已经声明缓冲区const char* buf;
稍后我想使用 memset 重新分配大小
buffer_len = 1024;
memset(buf, '\0', buffer_len);
buf[strlen(buf)-1]='\0';
给出错误:
client.cpp:73:30: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive]
In file included from client.cpp:2:0:
/usr/include/string.h:62:14: error: initializing argument 1 of ‘void* memset(void*, int, size_t)’ [-fpermissive]
client.cpp:75:21: error: assignment of read-only location ‘*(buf + (((sizetype)strlen(buf)) + -1u))’
我知道这是由于const
但有任何替代或方法来执行它的事件它是 const 吗?