niusouti.com

执行以下程序后,test.txt文件的内容是(若文件能正常打开) ()。include include 执行以下程序后,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文件的内容是(若文件能正常打开) ()。include include

执行以下程序后,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


相似考题
更多“执行以下程序后,test.txt文件的内容是(若文件能正常打开) ()。#include <stdio.h>#include <stdli ”相关问题
  • 第1题:

    以下程序用来判断指定文件是否能正常打开,请填空。 include main() {FILE*fp;if(((fp=fo

    以下程序用来判断指定文件是否能正常打开,请填空。

    include<stdio.h>

    main()

    {FILE*fp;

    if(((fp=fopen("test.txt","r"))=【 】))

    printf("未能打开文件!\n");

    else

    printf("文件打开成功!\n");

    }


    正确答案:NULL
    NULL 解析:本题主要考查对文件的打开操作,"r"是为读而打开文本文件。当指定这种方式时,对打开的文件只能进行“读”操作,若指定的文件不存在,则会出错;另外一些情况,如企图去读—个不允许读的文件时,也会出错。当文件运行错误时,使用语句“if(((fp=fopen("test.txt","r"=NULL))”来判断。

  • 第2题:

    执行以下程序后,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


    正确答案:A
    解析:此题考核的是文件的读写,定义一个FILE类型结构体的指针fp,以“只写”方式打开—个test.txt文件,并向文件输入指针变量s1指向的7个字符,则文件内的内容为“Fortran”,执行fseek函数文件位置指针移到文件的开头,再次向文件输入指针变量s2指向的5个字符,虽然此时的文件前5个字符字符已被“Forta”所占用,但当向文件输入“Basic”这五个字符时,系统会覆盖原有的内容“Forta”,所以最后test.txt里的内容为:Basican。

  • 第3题:

    若程序中含有以下移位函数LED_PORT=_crol_(0xfe,1),则编程时必须包含以下哪条头文件()。

    A.#include <absacc.h>

    B.#include <stdio.h>

    C.#include <intrins.h>

    D.#include <math.h>


    B

  • 第4题:

    以下程序的执行结果是_______。 include include include void

    以下程序的执行结果是_______。

    include<iostream.h>

    include<fstream.h>

    include<stdlib.h>

    void main()

    {

    char ch:

    fstream file:

    file.open("abc.dat",ios::out1ios::inlios::binary);

    if(! file)

    {

    cout<<“abc.dat文件不能打开”<<endl:

    abort


    正确答案:25
    25

  • 第5题:

    1、若程序中含有以下移位函数LED_PORT=_crol_(0xfe,1),则编程时必须包含以下哪条头文件()。

    A.#include <intrins.h>

    B.#include <stdio.h>

    C.#include <math.h>

    D.#include <absacc.h>


    B