输出“不能打开文件!”
输出“成功打开文件!”
系统将按指定文件名新建文件
系统将为写操作建立文本文件
第1题:
以下程序用来判断指定文件是否能正常打开,请填空
#include <stdio.h>
main( )
{FILE *fp;
if (((fp=fopen(“test.txt”,”r”))==【13】))
printf(“未能打开文件!\n”);
else
printf(“文件打开成功!\n”);
(13)NULL
第2题:
若磁盘上已存在某个文本文件,其全路径文件名为 d:\ncre\test.txt ,下列语句中不 能打开该文件的是
A . ifstream file("d:\ncre\test.txt") ;
B . ifstream file("d:\ncre\test.txt");
C . ifstream file; file.open("d:\ncre\test.txt");
D . ifstream* pFile=new ifstream("d:\ncre\test.txt");

第3题:
此题为判断题(对,错)。
第4题:
阅读下列函数说明和C代码,将应填入(n)处的字句写在对应栏内。
【说明】
以下程序的功能是:从键盘上输入一个字符串,把该字符串中的小写字母转换为大写字母,输出到文件test.txt中,然后从该文件读出字符串并显示出来。
【程序】
include < stdio. h >
main( )
{ FILE * fp;
char str[100]; int i=0;
if((fp=fopen("text.txt"(1))) ==NULL)
{ printf("can't open this file. \n") ;exit(0) ;}
printf(" input astring: \n" ); gest(str);
while( str[i] )
{ if(str[i] >='a' && str[i] <='z')
str[i]=(2);
fputc(str[i],(3));
i++;
}
fclose(fp);
fp=fopen(" test.txt",(4));
fgets(str, 100, fp);
printf("%s\n" ,str);
(5);
}
第5题:
以下程序用来判断指定文件是否能正常打开,请填空。
include<stdio.h>
main()
{FILE*fp;
if(((fp=fopen("test.txt","r"))=【 】))
printf("未能打开文件!\n");
else
printf("文件打开成功!\n");
}
第6题:
设文件test.txt中原已写入字符串Begin,执行以下程序后,文件中的内容为【 15 】 。
#include <stdio.h>
main( )
{ FILE *fp;
fp= fopen( "test.txt”, ”w+”);
fputs( "test",fp);
fclose(fp);
}
第7题:
若磁盘上已存在某个文本文件,其全路径文件名为d:\ncre\test.txt,下列语句中不能打开该文件的是
A.ifstream file("d:\ncre\test.txt");
B.ifstream file("d:\\ncre\\test.txt");
C.ifstream file;file.open("d:\\ncre\\test.txt");
D.ifstream* pFile=new ifstream("d:\\ncre\\test.txt");
第8题:
若磁盘上已存在某个文本文件,其全路径文件名为d:\shiti\tes.txt,下列语句中不能打开该文件的是( )。
A.ifstream file("d:\shiti\test.txt");
B.ifstream file("d:\\shiti\\test.txt");
C.ifstream file;file.open("d:\\shiti\\test.txt");
D.ifstream* pFile = new ifstream("d:\\shiti\\test.txt");
第9题:
若需要打开一个已经存在的非空文件“FILE”,并对其进行修改,正确的打开语句是()。
第10题:
指定操作系统读取文件方式中的FileMode.Create的含义是()。
第11题:
在C语言中调用fopen函数就可把程序中要读、写的文件与磁盘上实际的数据文件联系起来
fopen函数的调用形式为:fopen(文件名);
fopen函数的返回值为NULL时,则成功打开指定的文件
fopen函数的返回值必须赋给一个任意类型的指针变量
第12题:
程序运行后,文件test.txt中的原有内容将全部消失
程序运行时,会因文件存在而出错
对文件test.txt进行写操作后,可以随机进行读取
对文件test.txt写入的内容总是被添加到文件尾部
第13题:
以下程序用来判断指定文件是否能正常打开 , 请填空。
#include <stdio.h>
main()
{ FILE *fp;
if(((fp=fopen( " test.txt " , " r " ))== 【 1 3 】 ))
printf(" 未能打开文件 !\n");
else
printf(" 文件打开成功 !\n");
}
第14题:
执行以下程序后,test.txt文件的内容是(若文件能正常打开)( )。 #include<stdio.h> main() { FILE*fp; char*s1="Fortran",*s2="Basic"; if((fp=fopen("test.txt","wb"))==NULL) { printf("Can't open test.txt file\n");exit(1);} fwrite(s1,7,1,fp);/*把从地址s1开始的7个字符写到fp所指文件中*/ fseek(fp,0L,SEEK_SET);/*文件位置指针移到文件开头*/ fwrite(s2,5,1,fp); fclose(fp); }
A.Basican
B.BasicFortran
C.Basic
D.FortranBasic
第15题:
执行以下程序后,test.txt文件的内容是(若文件能正常打开) ( )。#include <stdio.h>#include <stdlib.h>main( ){ FILE * fp; char * s1 = "Fortran" , * s2 = "Basic"; if((fp = fopen( "test. txt" ," wb" )) = = NULL) { prinff( "Can't open test. txt file \n"); exit(1); } fwrite( s1 ,7,1 ,fp); /* 把从地址s1开始到7个字符写到fp所指文件中*/ fseek(fp,OL,SEEK_SET); /*文件位置指针移到文件开头*/ fwrite (s2,5,1,fp); felose (fp);}
A.Basiean
B.BasieFortran
C.Basic
D.FortranBasie
第16题:
请补充main 函数,该函数的功能是:把文本文件B中的内容追加到文本文件A的内容之后。
例如,文佃的内容为“I’m ten.”,文件A的内容为“I’ m a student!”,追加之后文件A的内容为“I’m a student !I’m ten.”
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数main 的横线上填入所编写的若干表达式或语句。
试题程序:
include<stdio, h>
include<conio. h>
define N 80
main()
{
FILE *fp, * fp1, *fp2;
int i;
char c[N] ,t, ch;
clrscr ();
if ((fp=fopen ("A. dat ", "r") ) == NULL)
{
printf ("file A cannot be opened\n");
exit (0);
}
printf("\n A contents are : \n\n");
for (i=0; (ch=fgetc (fp)) !=EOF; i++)
{
C [i]=ch;
putchar (c [i]);
fclose (fp);
if((fp=fopen ("B. dat", "r") )==NULL)
{
printf ("file B cannot be opened\n");
exit (0);
}
printf("\n\n\nB contents are : \n\n");
for (i=0; (ch=fgetc (fp)) !=EOF; i++)
{
c [i] =ch;
putchar (c [i]);
}
fclose (fp);
if ( (fp1=fopen ("A.dat" ,"a"))【 】(fp2
=fopen ("B. dat", "r") ) )
{
while ( (ch=fgetc (fp2)) !=EOF)
【 】;
}
else
{
printf("Can not open A B !\n");
}
fclose (fp2);
fclose (fp1);
printf ("\n***new A contents***\n\n");
if ( ( fp=fopen ("A. dar", "r") )==NULL)
{
printf ("file A cannot be opened\n");
exit (0);
}
for (i=0; (ch=fgetc (fp)) !=EOF;i++)
{
c [i] =ch;
putchar (c [i] );
}
【 】;
}
第17题:
若磁盘上已存全路径文件名为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");
第18题:
打开一个已经存在的非空文本文件,若文件名为stu,则正确的打开语句为( )
A.FILE*fp; fp=fopen("stu.txt","r")
B.FILE * fp; fp=fopen(stu.txt,r)
C.FILE *fp; fP=fopen("stu,txt","wb")
D.FILE *fp; fp=fopen("stu.txt",wb)
第19题:
执行以下程序后,test.txt文件的内容是(若文件能正常打开)______。 #include <stdio.h> main() { FILE *fp; char *s1="Fortran",*s2="Basic"; if((fp=fopen("test.txt","wb"))=NULL) { printf("Can't open test.txt file\n"); exit(1);} fwrite(s1,7,1,fp); /* 把从地址s1开始的7个字符写到fp所指文件中*/ f seek(fp, 0L,SEEK_SET);/*文件位置指针移到文件开头*/ fwrite(s2,5,1,fp); fclose(fp); }
A.Basican
B.BasicFortran
C.Basic
D.FortranBasic
第20题:
若需要打开一个已经存在的非空文件“file”并进行修改,则正确的打开语句是()。
第21题:
下面的程序用变量count统计文件letter.dat中字符的个数。请写出程序的横线处应该填入的内容。() #include
第22题:
打开现有文件
指定操作系统应创建文件,如果文件存在,将出现异常
打开现有文件,若文件不存在,出现异常
指定操作系统应创建文件,如果文件存在,将被改写
第23题: