{printf("Cannotopenfile!\n");exit(0);}
for(i=0;i<1 - 高级语言程序设计(一)(00342) - 专业知识收录平台"> {printf("Cannotopenfile!\n");exit(0);}
for(i=0;i<1 - 高级语言程序设计(一)(00342) - 专业知识收录平台">
当前位置:首页 > 高级语言程序设计(一)(00342) > 正文内容

阅读下列程序,写出程序运行的输出结果。
设程序在运行时,从键盘上输入:1234567890回车换行键。
#include
#include
voidmain()
{FILE*fp;
inti;
charch;
if((fp=fopen("CCW.txt","W"))==NULL)
{printf("Cannotopenfile!\n");exit(0);}
for(i=0;i<1

高老师2年前 (2024-03-26)高级语言程序设计(一)(00342)11

阅读下列程序,写出程序运行的输出结果。
设程序在运行时,从键盘上输入:1234567890回车换行键。
#include
#include
voidmain()
{FILE*fp;
inti;
charch;
if((fp=fopen("CCW.txt","W"))==NULL)
{printf("Cannotopenfile!\n");exit(0);}
for(i=0;i<10;i++)
{scanf("%C",&ch);fputc(ch,fp);
}
fclose(fp);
if((fp=fopen("CCW.txt","r"))==NULL)
{prinff("Cannotopenfile!\n");exit(0);}
fseek(fp,4L,SEEK_SET);/*定位到由文件头开始后移4个字节处*/
while(!feof(fp))fputc(fgetc(fp),stdout);/*逐个字符进行输出*/
fclase(fp);
}

输出结果:567890

扫描二维码免费使用微信小程序搜题/刷题/查看解析。

版权声明:本文由翰林刷题小程序授权发布,如需转载请注明出处。

本文链接:https://doc.20230611.cn/post/442098.html

分享给朋友: