io02.c

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 35 行

C
35
字号
#include "fail.h"
// Listing 8 - iomanip.h Macro Version

//#define IOMANIPdeclare(T) SMANIP_define(T)
//#define OMANIP(T) OMANIP##T

#include <iostream.h>
#include <iomanip.h>
#include <strstrea.h>
#include <string.h>

typedef ostream OS; // an abbrev
typedef char* CP;    // single token

IOMANIPdeclare(CP);

// qSTR - manip function
OS& qSTR(OS& os,CP s)
{ return os << "'" << s << "'"; }

// qStr - manip inteface
// for manip function qSTR
OMANIP(CP) qStr(CP s)
{ return OMANIP(CP)(qSTR,s); }

int main()
{
    // sample output expression
    strstream out;
    out << "Output is a " << qStr("string") << ends;
    char *p = out.str();
    if( strcmp( p, "Output is a 'string'" ) != 0 ) fail(__LINE__);
    _PASS;
}

⌨️ 快捷键说明

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