fig11_19.cpp

来自「经典vc教程的例子程序」· C++ 代码 · 共 34 行

CPP
34
字号
// Fig. 11.19: fig11_19.cpp 
// Creating and testing user-defined, nonparameterized 
// stream manipulators.
#include <iostream.h>

// bell manipulator (using escape sequence \a)
ostream& bell( ostream& output ) { return output << '\a'; }

// ret manipulator (using escape sequence \r)
ostream& ret( ostream& output ) { return output << '\r'; }

// tab manipulator (using escape sequence \t)
ostream& tab( ostream& output ) { return output << '\t'; }

// endLine manipulator (using escape sequence \n
// and the flush member function)
ostream& endLine( ostream& output ) 
{ 
   return output << '\n' << flush;
}

int main()
{
   cout << "Testing the tab manipulator:" << endLine
        << 'a' << tab << 'b' << tab << 'c' << endLine
        << "Testing the ret and bell manipulators:"
        << endLine << "..........";
   cout << bell;
   cout << ret << "-----" << endLine;
   return 0;
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?