填空题

下列程序的主要功能是()。 
#include 
main( ) { 
    FILE *in,*out; 
    char ch,infile[10],outfile[10];
     printf(“Enter the infile name:\n”);
     scanf(“%s”,infile); 
    printf(“Enter the outfile name:\n”);
     scanf(“%s”,outfile); 
    if((in=fopen(infile, “r”))==NULL){
         printf(“Cannot open infile\n”);
         exit(0);
     } 
if((out=fopen(outfile, “w”))==NULL){
         printf(“Cannot open outfile\n”);
         exit(0);
     } 
    while(!feof(in)) 
        fputc(fgetc(in),out);
     fclose(in);
     fclose(out); 
}


您可能感兴趣的试卷

你可能感兴趣的试题

5.单项选择题若以“a+”方式打开一个已经存在的文件,则下列叙述中,正确的是()。

A.文件打开时,原有文件内容不被删除,位置指针移到文件的末尾,可作添加和读操作
B.文件打开时,原有文件内容不被删除,位置指针移到文件的开头,可作重写和读操作
C.文件打开时,原有文件内容被删除,只可作写操作
D.以上各种叙述都不正确

6.单项选择题函数fgetc的作用是从指定文件中读入一个字符,该文件的打开方式必须是()。

A.只写
B.追加
C.读或读写
D.答案B和C都正确

8.单项选择题

以下scanf函数调用语句中对结构体变量成员的不正确引用的是()。 
struct node{ 
    char name[20];
     int age;
     int sex;
}student[5],*p; 
p=student; 

A.scanf(“%s”,student[0].name);
B.scanf(“%d”,&student[0].age);
C.scanf(“%d”,&(p->sex));
D.scanf(“%d”,p->age);

9.单项选择题当说明一个结构体变量时,系统分配给它的内存是()。

A.各成员所需要的内存量的总和
B.结构中第一个成员所需要的内存量
C.成员中占内存量最大者所需要的内存量
D.结构中最后那个成员所需要的内存量