Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 重置C+中的输出标志+;_C++_Iostream_Flags_Iomanip - Fatal编程技术网

C++ 重置C+中的输出标志+;

C++ 重置C+中的输出标志+;,c++,iostream,flags,iomanip,C++,Iostream,Flags,Iomanip,我打算使用resetiosglags函数将我结束的行上的所有输出标志重置为默认值。当我试图以这种方式进行操作时,它会提供错误的输出,这与我的预期相反 #include <iostream> #include <iomanip> using namespace std; int main() { bool first; int second; long third; float fourth; float fifth; dou

我打算使用
resetiosglags
函数将我结束的行上的所有输出标志重置为默认值。当我试图以这种方式进行操作时,它会提供错误的输出,这与我的预期相反

#include <iostream>
#include <iomanip>
using namespace std;
int
main()
{
    bool first;
    int second;
    long third;
    float fourth;
    float fifth;
    double sixth;

    cout << "Enter bool, int, long, float, float, and double values: ";
    cin >> first >> second >> third >> fourth >> fifth >> sixth;
    cout << endl;

// ***** Solution starts here ****
    cout << first << " " << boolalpha << first  << endl << resetiosflags;
    cout << second << " " << showbase << hex << second << " " << oct << second << endl << resetiosflags;
    cout << third << endl;
    cout << showpos << setprecision(4) << showpoint << right << fourth << endl << resetiosflags;
    cout << scientific << fourth << endl << resetiosflags;
    cout << setprecision(7) << left << fifth << endl << resetiosflags;
    cout << fixed << setprecision(3) << fifth << endl << resetiosflags;
    cout << third << endl;
    cout << fixed << setprecision(2) << fourth << endl << resetiosflags;
    cout << fixed << setprecision(0) << sixth << endl << resetiosflags;
    cout << fixed << setprecision(8) << fourth << endl << resetiosflags;
    cout << setprecision(6) << sixth << endl << resetiosflags;
// ***** Solution ends here ****

    cin.get();
    return 0;
}
#包括
#包括
使用名称空间std;
int
main()
{
布尔优先;
int秒;
长第三;
浮动第四;
浮动第五;
双六;
cout>第一>>第二>>第三>>第四>>第五>>第六;
库特

std::resetiosglags()
是一个用于表达式中的操纵器,例如
out
resetiosglags
是一个接受一个参数的函数。您不是在调用它,而是在打印它的地址。@IgorTandetnik鉴于我打算重置在每个语句末尾打开的标志,我应该考虑什么方法?
/*unspecified*/ resetiosflags( std::ios_base::fmtflags mask );
std::cout << ... << std::resetiosflags(std::ios_base::boolalpha);
std::cout << ... << std::noboolalpha;