当前位置:文档之家› 第10章-输入输出流

第10章-输入输出流

1.下列流类中可以用于处理文件的是()。

Empty! (D)
(a) ios (b) iostream (c) strstream (d) fstream
2.在下列选项中()是istream类的对象。

Empty! (B)
(a) cerr (b) cin (c) clog (d) cout
3.read函数的功能是从输入流中读取()。

Empty! (D)
(a) 一个字符(b) 当前字符(c) 一行字符(d) 指定若干个字节
4.下列选项中,用于清除基数格式位设置以十六进制输出的语句是()。

Empty! (B)
(a) cout << setf( ios::dec, ios::basefield ) ;
(b) cout << setf( ios::hex, ios::basefield ) ;
(c) cout << setf( ios::oct, ios::basefield ) ;
(d) cin >> setf( ios::hex, ios::basefield ) ;
5.下列格式控制符,既可以用于输入,又可以用于输出的是()。

Empty! (A)
(a) setbase (b) setfill (c) setprecision (d) setw
6.下列串流类,在strstream.h中定义的是()。

Empty! (B)
(a) istringstream (b) istrstream (c) ostringstream (d) stringstream 7.包含类fstream定义的头文件是()。

Empty! (A)
(a) fstream.h (b) ofstream.h (c) ifstream.h (d) iostream.h
8.要求打开文件 D:\file.dat,并能够写入数据,正确的语句是()。

Empty! (D)
(a) ifstream infile( "D:\\file.dat", ios::in ) ;
(b) ifstream infile( "D:\\file.dat", ios::out ) ;
(c) ofstream outfile( "D:\\file.dat", ios::in ) ;
(d) fstream iofile( "D:\\file.dat", ios::in | ios::out ) ;
9.设已定义浮点型变量data,以二进制方式把data的值写入输出文件流对象outfile中去,正确的语句是()。

Empty! (C)
(a) outfile.write( ( double * ) & data , sizeof( double ) ) ;
(b) outfile.write( ( double * ) & data , data ) ;
(c) outfile.write( ( char * ) & data , sizeof( double ) ) ;
(d) outfile.write( ( char * ) & data , data ) ;。

相关主题