[英]C++ Formatting Using Iomanip
I am trying to format the output of my code using iomanip: 我正在尝试使用iomanip格式化我的代码输出:
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2) << "Modified: resistor "<< rname << " to "<< res << " Ohms"<<endl;
but i recieve an error on the third line: 但我收到第三行的错误:
error: invalid operands of types 'std::streamsize' and 'const char [20]' to binary 'operator<<'|
Use 采用
std::cout << std::setprecision(2) << ... << '\n';
or: 要么:
std::cout.precision(2);
std::cout << ... << '\n';
The function ios_base::precision
does not return the stream it operates on, so you can't stream anything into it directly. 函数
ios_base::precision
不返回它所操作的流,因此您无法直接将任何内容流入其中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.