能否请您告诉我如何将 buf vector 的大小更改为动态长度?
long five = 555;
char buf[256];
snprintf(buf, sizeof(buf), "%d", five);
谢谢!
如何使用 std::vector<std::string>buf;
更改我的代码才能正常工作?
我有错误:
vector is not a member of std;
buf was not declared in this scope and error: expected primary-expression before ">" token
最佳答案
在 C++ 中,你不能。您将不得不以某种方式动态分配它,或者更好的是仍然使用像 std::vector 这样的动态数据结构。
关于c++ - 初始化具有动态长度的 vector ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6018254/