我使用Visual C++将我的游戏从GNU/Linux移植到Windows。“表达式必须具有恒定值”,同时使用ofstream
这里的问题是:
std::stringstream sstm;
/// *working on stringstream*
const int size = sstm.str().size();
char buffer[size];
std::ofstream outfile("options", std::ofstream::binary);
for(int i = 0; i < size; i++)
buffer[i] = sstm.str().at(i);
outfile.write(buffer, size);
outfile.close();
它说:“表达必须有一个恒定的值”缓冲中的声明。
我已经改成了这样:
std::vector<char>buffer(size);
然后VC说:在outfile.write “不能 '的std ::矢量< _Ty>' 到 '为const char *' 转换参数1”( )。