求助!!
请大哥帮我开一下这两个代码哦!!
我先创建了一个文件,如下形式,并且在文件中输入呢5个dd!但是我在在编写一段代码打开的时候去只输出呢3个d!!请问是什么问题呢!!
创建文件代码!
#include "stdio.h"
#include "stdlib.h"
void main()
{
FILE *fp;
char ch;
if((fp=fopen("e:\\file\\dd.txt","w"))==NULL)
{
printf("cannot creat the file\n");
exit(0);
}
do
{
ch=getchar();
fputc(ch,fp);
putchar(ch);
}
while(ch!='!');
fclose(fp);
}
//打开一个文件代码!!
#include "stdio.h"
#include "stdlib.h"
void main()
{
FILE *fp;
char ch;
if((fp=fopen("e:\\file\\dd.txt","r"))==NULL)
{
printf("cannot open the file\n");
exit(0);
}
do
{
ch=fgetc(fp);
fputc(ch,fp);
putchar(ch);
}
while(ch!=EOF);
fclose(fp);
}