cpp10.cpp

来自「C++参考书」· C++ 代码 · 共 29 行

CPP
29
字号

// Coded by plusir -- Jan.09.2003.
// Standard C++ Bible -- (P539-19-10)

#include <fstream>
#include <cctype>
using namespace std ;

int main()
{
	char *fname = "test.txt" ;

	ifstream tfile( fname, ios::in | ios::out | ios::binary ) ;
	ostream ofile( tfile.rdbuf() ) ;

	char tdata[100] ;
	int i = 0 ;
	while ( !tfile.eof() && i < sizeof tdata )
		tfile.get( tdata[i++] ) ;

	ofile.seekp( 0, ios::end ) ;
	ofile << "\r\n" ;

	for ( int j = 0; j < i - 1; ++j )
		ofile.put( static_cast<char>( toupper( tdata[j] ) ) ) ;

	return 0 ;
}

⌨️ 快捷键说明

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