A.fclose
B.fpoen
C.fgetc
D.fread
第1题
第2题
FILE *myf;ling f1;
myf=______("test.t","1.b");
fseek(myf,0,SEEK_END);f1=ftel(myf);
fclose(myf);
printf("%d\n",f1);
第3题
第4题
4. 下面是一个文件打不开的异常处理程序,分析程序并完成相应问题。 (1)若磁盘中没有myfile.txt 文件,则输出结果如何? (2分) (2)说明特定模板函数的作用。(3分) #include<fstream> #include<iostream> using namespace std; int main() { ifstream source("myfile.txt"); //打开文件 char line[128]; char ss[] = "myfile.txt"; try { if (!source) throw ss; // 如果打开失败,抛出异常 } catch (char * s) { cout << "error opening the file " << s << endl; exit(1); } while (!source.eof()) //判断是否到文件末尾 { source.getline(line, sizeof(line)); cout << line << endl; } source.close(); return 0; }
第5题
A.用fopen函数时一般会判断打开文件操作是否出错
B.在C程序中直接使用文件名来访问文件
C.文本文件和二进制文件的数据存储方式是不同的
D.C语言把文件看成是一个字节的序列
第6题
A、打开文件的目的都是为了向文件中写入内容
B、打开一个全新的文件时都是定位在文件开头
C、打开一个已经存在的文件时都是定位在文件末尾
D、打开文件后都不允许从文件中读出内容
第7题
注意:不得删行或增行,也不得更改程序结构。
文件RevMain5.cpp中的程序清单如下:
//RevMain5.cpp
include<iostream>
include<iomanip>
using namespace std;
int main()
{
void sort(int array[],int n);
int data[10],*p,i;
cout<<"Input 10 numbers\n";
for (i=0; i<10; i++)
cin>>data [i];
cout<<"the origined array is:";
for (p=data;p<data+10;p++)
{
if((p-&data[0]) %5==0)
cout<<" \n";
cout<<setw (5) <<*p;
}
sort (data, 10);
cout<<"\n the present array is:";
for(p=data;p〈data+10;p++)
{
if((p-&data[0])%5==0) cout<<"\n";
cout<<setw (5)<<*p;
}
}
void sort(int array[],int n)
{
/* * * * * * * * *found * * * * * * * * * */
for(p1=array;p1<array+(n-1) ;p1++)
{
for (p2=p1+1 ;p2<array+n;p2++)
{
if (*p1>*p2)
{
/* * * * * * * * *found * * * * * * * * * */
temp=*p1; *p1=*p2; *p2=*p1;
}
}
}
}
第8题
A、FILE *fp; fp=fopen("test.dat", "rb");
B、FILE*fp; fp=fopen("test.dat", "r+");
C、FILE *fp; fp=fopen("test.dat", "r");
D、FILE *fp; fp=fopen("test.dat", "rb+");
第9题
第10题
A.要从一个文件读数据,应用程序首先要调用操作系统函数并传送文件名,并选择一个到该文件的路径来打开文件
B.文件控制块(FCB)对于打开的文件是惟一的识别依据
C.要从文件中读取一块数据,应用程序需要调用函数ReadFile,并将文件句柄在内存中的地址和要复制的字节数传送给操作系统
D.操作系统所以能够找到磁盘上的文件,是因为有磁盘上的文件名的存储位置的记录
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!