io04.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 43 行
C
43 行
#include "fail.h"
#include <string.h>
#include <strstrea.h>
int main() {
{
ostrstream os;
os << ends;
if( strcmp( os.str(), "" ) != 0 ) fail(__LINE__);
}
{
ostrstream os;
os << "123";
os << ends;
if( strcmp( os.str(), "123" ) != 0 ) fail(__LINE__);
}
{
ostrstream os;
os << "123";
os.width( 6 );
os << "456";
os << ends;
if( strcmp( os.str(), "123 456" ) != 0 ) fail(__LINE__);
}
{
ostrstream os;
os << "123";
os.width( 6 );
os << "456";
os.width( 3 );
os.flags( os.flags() | ios::left );
os.write( "789", 3 ); // shouldn't affect 'width'
os << "";
os << ends;
if( strcmp( os.str(), "123 456789 " ) != 0 ) fail(__LINE__);
}
_PASS;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?