#include <stdio.h>
#include <string.h>
int main()
{ FILE *p;
char ch;
p=fopen("abc.txt","w");
ch=fgetc(stdin);
while(ch!= '#')
{ fputc(ch,p);
ch=fgetc(stdin);
}
return 0;}
这段代码不知道哪里有问题
没什么问题啊
??有什么问题
我这边是正常的啊
试试这个?
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
FILE *fp = fopen("abc.txt", "rb");
char c ;
while(c!=EOF)
{
c = fgetc (fp);
printf("%c",c);
}
//测试了是可以打印文件全部内容的
return 0;
}
单单写入文件的话这代码没啥问题啊:
#include <stdio.h>
#include <string.h>
int main()
{ FILE *p;
char ch;
p=fopen("abc.txt","w");
ch=fgetc(stdin);
while(ch!= '#')
{ fputc(ch,p);
ch=fgetc(stdin);
}
return 0;
}
写入12345:
不好意思😅,打扰大家了,代码没问题,不好意思不好意思😬