CMS专题

单选题对OPEN(4,FILE=‘BB.DAT’,STATUS=‘OLD’,语句,下面哪个描述是正确的()?A 打开一个有格式顺序文件,可以读文件B 打开一个有格式直接文件,可以写文件C 打开一个有格式直接文件,可以读写D 打开一个直接文件

题目
单选题
对OPEN(4,FILE=‘BB.DAT’,STATUS=‘OLD’,语句,下面哪个描述是正确的()?
A

打开一个有格式顺序文件,可以读文件

B

打开一个有格式直接文件,可以写文件

C

打开一个有格式直接文件,可以读写

D

打开一个直接文件

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

下面关于文件操作的代码可能触发异常()file, err := os.Open("test.go")defer file.Close()if err != nil { fmt.Println("open file failed:", err) return}...

此题为判断题(对,错)。


参考答案:对

第2题:

下面程序的运算结果是()。includeusing namespace std;class A{public:virtual void f

下面程序的运算结果是( )。 #include<iostream> using namespace std; class A { public: virtual void fun()=0; }; class B:public A } public: void fun() {cout<<"new file"<<" ";} }; class C:public A { public: void fun() { cout<<"open file"<<" ";} }; void main() { A a, * p; B b;C c; p=&c; p->fun(); p=&b; }

A.new file open file

B.new file new file

C.编译出错

D.open file new file


正确答案:C
解析:语句Aa,*p;用抽象类说明了一个对象,这是不允许的。若把其改为A*p;则程序运行结果为D。

第3题:

( 16 )要建立文件流并打开当前目录下的文件 file.dat 用于输入,下列语句中错误的是

A ) ifstream fin=ifstream.open ( "file.dat" ) ;

B ) ifstream*fir.=new ifstream ( "file.dat" ) ;

C ) ifstream fin; fin.open ( "file.dat" ) ;

D ) ifstream *fin=new ifstream ( ) ; fin 一 >open ( "file.dat" ) ;


正确答案:A

第4题:

下列可以打开随机文件的语句是( )。

A.Open"file 1.dat"For Input As#1

B.Open"file1.dat"For Append As#1

C.Open"file1.dat"For Output As#1

D.Open"file1.dat"For Randow As#1 Len=20


正确答案:D
D。【解析】本题主爵考查随机文件与顺序文件的特点与区别及文件操作的特点。VisualBasic中有3种文件访问的类型:顺序文件、随机文件、二进制文件。随机文件又称直接存取文件,简称随机文件或直接文件。随机文件的每个记录都有一个记录号,在写入数据时只要指定记录号,就可以把数据直接存入指定位置。而在读取数据时,只要给出记录号,就可直接读取。在记录文件中,可以同时进行读、写操作,所以能快速地查找和修改每个记录,不必为修改某个记录而像顺序文件那样.对整个文件进行读、写操作。其优点是数据存取较为灵活,方便,速度快,容易修改,主要缺点是占空间较大,数据组织复杂。顺序文件:顺序文件将文件中的记录一个接一个地按顺序存放。二进制访问能提供对疋件的完全控制,因为文件中的字节可以代表任何东西,当要使文件的尺寸尽量小时,应使用二进制访问。在文件处理过程中,执行完Open操作后,程序将生成一个文件指针,程序可以调用LOF函数来获得返回给文件分配的字节数。在随机文件中,每个记录的长度是固定的,记录中的每个字段的长度也是固定的。因为是操作随机文件,所以选D。

第5题:

要建立文件流并打开当前目录下的文件6le.dat用于输入,下列语句中错误的是( )。

A.ifstream fin=ffstream.open(”file.dat”);

B.ifstream*fin=new ifstream(”file.dat”);

C.ifstream fin;fin.open(”file.dat”);

D.ifstream*fin=new ifstream;fin->open(”file.dat”);


正确答案:A
本题考查对文件流输入的操作,可以调用文件流的成员函数pen,一般形式如下:文件流对象.0pen(磁盘文件名,输入/输出方式)。根据以上格式,可以判断A选项错误。

第6题:

下面哪种方法读文件“input.txt”是正确的()。

A、in_file = open('input.txt','w')

B、in_file = open('input.txt',r)

C、in_file = open('input.txt','r')

D、都不正确


参考答案:B

第7题:

若磁盘上已存全路径文件名为c:\ctest\test.txt的文件,下面语句中不能打开该文件的是( )。

A.ifstream *pFile=new ifstream("c:\\ctest\\test.txt");

B.ifstream file("c:\\ctest\\test.txt");

C.ifstream file;file.open("c:\\ctest\\test.txt");

D.ifstream file("c:\etest\test.txt");


正确答案:D

第8题:

下面程序的预设功能是:统计文件abc.txt中的字符个数。 include include

下面程序的预设功能是:统计文件abc.txt中的字符个数。

include <iostream.h>

include <fstream.h>

include <stdlib.h>

void main()

{

fstream file;

file.open( "abc.txt", ios::in);

if ( !file )

{

cout<<"Can not open abc.txt"<<end1;

abort();

}

char ch;

int i = O;

while (______________)

{

file.get(ch);

i++;

}

cout<<"Characters : "<<i<<end1;

file.close();

}

则程序中空白处应该填入的语句是【 】。


正确答案:!file.eof()
!file.eof() 解析:文件流对象的成员函数eof的功能是再进行输入操作时,若达到文件尾则返回true,否则返回false。程序的while循环中调用set()成员函数进行输入操作,循环结束的条件是操作到文件尾部。

第9题:

为丫从当前文件夹中读入文件File1.txt,某人编写了下面的程序: Private Sub Command1_Click( ) Open"File1.txt"For Output As#20 Do While Not EOF(20) Line Input#20,ch$ Print ch Loop Close#20 End Sub 程序调试时,发现有错误,下面的修改方案中正确的是( )。

A.在Open语句中的文件名前添加路径

B.把程序中各处的“20”改为“1”

C.把Print ch语句改为Print#20,ch

D.把Open语句中的0utput改为Input


正确答案:D
D。【解析】VB中文件操作有Input方式和Output方式,Input是从硬盘上把文件内容读入到内存,Output是将数据输出到文件。

第10题:

下面程序的结果是 ______。includeclass A{ public:virtual voidfun()=0{};};class

下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file\n" ;} }; void main() { A a,*p; B b; C c; D d; p=&c; p->fun (); p=&b; p->fun (); p=&d; p->fun(); }

A.new file open file save file

B.new file new file new file

C.编译出错

D.open file new file save file


正确答案:C

更多相关问题