我正在尝试使用iomanip格式化代码的输出:
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2) << "Modified: resistor "<< rname << " to "<< res << " Ohms"<<endl;但是我在第三行收到一个错误:
error: invalid operands of types 'std::streamsize' and 'const char [20]' to binary 'operator<<'|发布于 2013-09-29 00:47:56
使用
std::cout << std::setprecision(2) << ... << '\n';或者:
std::cout.precision(2);
std::cout << ... << '\n';函数ios_base::precision不返回它所操作的流,因此您不能直接将任何内容流式传输到它中。
https://stackoverflow.com/questions/19069290
复制相似问题