设程序在运行时,从键盘上输入: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