题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-05-01 02:16:00

[填空题]已有文本文件test.txt,其中的内容为:Hello,everyone!。以下程序中,文件test.txt已正确为“读”而打开,由此文件指针fr指向文件,则程序的输出结果是【 】。   #include <stdio.h>   main( )   {  FILE *fr; char str[40];     ......    fgets(str,5,fr);    printf("%s/n",str);    fclose(fr);   }

更多"已有文本文件test.txt,其中的内容为:Hello,everyon"的相关试题:

[填空题]已有文本文件test.txt,其中的内容为:Hello,everyone!。以下程序中,文件test.txt已正确为“读”而打开,由此文件指针fr指向文件,则程序的输出结果是【 】。   #include <stdio.h>   main( )   {  FILE *fr; char str[40];     ......    fgets(str,5,fr);    printf("%s/n",str);    fclose(fr);   }
[填空题]已有文本文件test.txt,其中的内容为:Hello, everyone!(,与everyone之间没有空格)。以下程序中,文件test.txt已正确为“读”而打开,由此文件指针fr指向文件,则程序的输出结果是______。
#include <stdio.h>
void main( )
FILE *fr; char str[40];
……
fgets(str,8,fr);
printf("%s/n",str);
fclose(fr);
[填空题]请补充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")) 【1】 (fp2 =fopen ("B. dat", "r") ) ) { while ( (ch=fgetc (f
[填空题]请补充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=
[填空题]在当前目录下有一个名为myfile.txt的文本文件,其中有若干行文本。下面程序的功能是读入此文件中的所有文本行,按行计算每行字符的ASCII码之和,并显示在窗体上。请填空。
Private Sub Command1_Click( )
Dim ch$, ascii As Integer
Open "myfile.txt" For (11) As #1
While Not EOF(1)
Line Input #1, ch
ascii=toascii( (12) )
Print ascii
Wend
Close #1
End Sub
Private Function toascii(myStr$) As Integer
n=0
For k=1 To (13)
n=n+Asc(Mid(myStr,k,1))
Next k
toascii=n
End Function
[简答题]【说明】 编写程序,生成一个新文本文件,它由一个已知文本文件的所有偶数行组成。要求已知文本文件名和新文本文件名均从键盘输入。请填空完善程序。 【C语言程序】 #include<stdio.h> main( ) { FILE *oldf,*newf; char ch,fname[20]; int i; do{ printf("Enter name of existed text file to be read:"); scanf("%s",fname); if((oldf=fopen(fname,"r"))==NULL) printf("File %s can’t open!/n",fname); }while(oldf==NULL); do{ printf("Enter mane of new text file to be written:"); scanf("%s",fname); if(( (1) ==NULL) printf("File %s can’t open!/n",fname); }while( (2) ); i=1; while(!feof(oldf)) { while((ch=fgetc(oldf))!= (3) ) { if(i%2== (4) ) fputc(ch,newf); } fputc(’/n’,newf); (5) ; } fclose(oldf); fclose(newf); }
[多项选择]【说明】
编写程序,生成一个新文本文件,它由一个已知文本文件的所有偶数行组成。要求已知文本文件名和新文本文件名均从键盘输入。请填空完善程序。
【C语言程序】
#include<stdio.h>
main( )

FILE *oldf,*newf;
char ch,fname[20];
int i;
do
printf("Enter name of existed text file to be read:");
scanf("%s",fname);
if((oldf=fopen(fname,"r"))==NULL)
printf("File %s can’t open!/n",fname);
while(oldf==NULL);
do
printf("Enter mane of new text file to be written:");
scanf("%s",fname);
if(( (1) ==NULL)
printf("File %s can’t open!/n",fname);
while( (2) );
i=1;
while(!feof(oldf))

while((ch=fgetc(oldf))!= (3) )

if(i%2== (4) )
fputc(ch,newf);

fputc(’/n’,newf);
(5) ;

fclose(oldf);
fclose(newf);

[填空题]在用通用对话框的ShowOpen显示“打开”文件对话框时,指定其中的文件类型为文本文件的格式为 【6】
[判断题]“资源管理器”是WindowsXP最常用的文件和文件夹管理工具,它可以将文本文件的部分内容复制到另一文件中。
[填空题]在当前目录下有一个名为“myfile.txt”的文本文件,其中有若干行文本。下列程序的功能是读入此文件中的所有文本行,按行计算每行字符的ASCII码之和,并显示在窗体上。请填空。
Private Sub Command1_Click( )
Dim ch$,ascii As Integer
Open"myfile.txt"For______AS#1
While NOt EOF(1)
Line Input#1.ch
ascii=toascii(______)
Print ascii
Wend
Close#1
End Sub
Private Function toascii(mystr$)As Integer
n=0
For k=1 To______
n=n+Asc(Mid(mystr,k,1))
Next k
toascii=n
End Function
[单项选择]假定当前盘符下有两个如下文本文件:
文件名 a1.txt a2.txt
内容 123# 321#
则下面程序段执行后的结果为
#include "stdio.h"
void fc(FILE *p)
char c;
while((c=fgetc(p))!=’#’)putchar(c);
main( )
FILE *fp;
fp=fopen("a1.txt","r");
fc(fp);
fclose(fp);
fp=fopen("a2.txt","r");
fc(fp);
fclose(fp);
putchar(’/n’);
A. 123321
B. 123
C. 321
D. 以上答案都不正确
[填空题]以下程序中用户由键盘输入一个文件名,然后输入一串字符(用$结束输入)存放到此文件中,形成文本文件,并将字符的个数写到文件尾部。请填空。 #include <string.h> main( ) { FILE*fp: char ch,fname[32] int count=0: prinft("input the filename:"): scanf("%s",fname); if((fp=fopen(______,"w+"))==NULL) { printf("can’t open file:%s/n",fname); exit(0): } printf("enter data:/n"): while((ch=getchar( ))!=’$’) {fputc(ch,fp): count++; } fprintf(______,"/n%d/n", count); fclose(fp): }
[单项选择]假定当前盘符下有两个文本文件,如下 文件名 a1.txt a2.txt 内容 123# 321# 则下面程序段执行后的结果为 #include"stdio.h" void fc(FILE*p) { char c; while((c=fgetc(p))!=’#’)putchar(c);} main( ) { FILE *fp; fp=fopen("a1.txt","r"); fc(fp); fclose(fp); fp=fopen("a2.txt","r"); fc(fp); fclose(fp); putchar(’/n/);}
A. 123321
B. 123
C. 321
D. 以上答案都不正确
[单项选择]

Hello everyone, this is the captain speaking, and I want to welcome you to Flight 18 heading for Seattle. Our flight time today is 2 hours and 14 minutes, and we will be flying at an average height of 29,000 feet. The local time in Seattle is a quarter to twelve (11:45), and the current weather is sunny, but there is a chance of rain later in the day. We will be arriving at Gate 13, and we will be announcing connecting flights on our nearing to the Seattle airport.
On behalf of Sky Airlines and the crew, I want to wish you an enjoyable stay in the Seattle area or at your final destination. Sit back and enjoy the flight.

What is the weather like in Seattle at present()
A. Partly cloudy.
B. Rainy.
C. Sunny.

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码