哥哥姐姐们帮我看下这个代码对不对呀,为啥我明明新建了文档,但是结果却总是说没办法打开呢

不瘦100斤不改网名 2019-12-24 10:49:53
谢谢 #include<stdio.h> #include<stdlib.h> void main() { FILE*fp; char ch,filename[20]; printf("please input the filename you want to write:"); scanf("%s",filename); if( !(fp==fopen(filename,"wt+")) ); { printf("cannot open the file!\n"); exit(0); } printf("please input the sentences you want to write:"); ch=getchar(); ch=getchar(); while( ch!=EOF ) { fputc(ch,fp); ch=getchar(); } fclose(fp); }
...全文
104 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
引用 3 楼 it_xiangqiang的回复:
希望对你有帮助:https://blog.csdn.net/it_xiangqiang/category_10581430.html 希望对你有帮助:https://blog.csdn.net/it_xiangqiang/category_10768339.html
谢谢大佬真的网站的模板怎么做不
源代码大师 2021-05-06
  • 打赏
  • 举报
回复
希望对你有帮助:https://blog.csdn.net/it_xiangqiang/category_10581430.html 希望对你有帮助:https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • 打赏
  • 举报
回复
引用 1 楼 自信男孩的回复:
#include<stdio.h>
#include<stdlib.h>

//void main()
int main()
{
FILE*fp;
char filename[20];
int ch; //定义为int,这样才能与EOF比较
printf("please input the filename you want to write:");
scanf("%s",filename);
//if( !(fp==fopen(filename,"wt+")) ); //为啥多一个分号, 为啥用==
if(!(fp=fopen(filename,"wt+")))
{
printf("cannot open the file!\n");
exit(0);
}
printf("please input the sentences you want to write:");
ch = getchar();
ch = getchar();
while( ch!=EOF )
{
fputc(ch,fp);
ch=getchar();
}
fclose(fp);

return 0;
}

供参考~
谢谢~~
自信男孩 2019-12-25
  • 打赏
  • 举报
回复
#include<stdio.h>
#include<stdlib.h>

//void main()
int main()
{
FILE*fp;
char filename[20];
int ch; //定义为int,这样才能与EOF比较
printf("please input the filename you want to write:");
scanf("%s",filename);
//if( !(fp==fopen(filename,"wt+")) ); //为啥多一个分号, 为啥用==
if(!(fp=fopen(filename,"wt+")))
{
printf("cannot open the file!\n");
exit(0);
}
printf("please input the sentences you want to write:");
ch = getchar();
ch = getchar();
while( ch!=EOF )
{
fputc(ch,fp);
ch=getchar();
}
fclose(fp);

return 0;
}

供参考~
在Windows系统中,notepad.exe(记事本)是一个“经典的”、“简洁的”文本编辑器。这个软件,有华丽的外观,也有繁杂的功能,仅仅是一个文本编辑小软件。虽然经过Windows系统数十年的变换,但它却保持着永恒姿态,数十年来几乎不曾改变过。曾经,VS中的经典DEMO中,就有它的身影,一个新建的项目,就藏有一个新建的“记事本”。然而,在WPF的项目中,“记事本”却消失的无影无踪,也许是很容易实现,也许是为了革新,而不愿再传承“经典”。确实,使用WPF技术再次让“记事本”复活,确实也是一件非常容易的事情。但是,如果,使用WPF技术,再搭配当下非常流行的MVVM模式呢?复活“记事本”的难度却陡然上升至很多WPF程序员为之默默叹气。而,MVVM模式是掌握WPF的最顶级技术,MVVM模式拥有的无尽的优势,让WPF相对于过往的编程模式来,是一种革命性的创新,从而也成为大中型WPF项目中必须的模式。但,学习难度。。。。。。在这个《WPF记事本开发详解》的课程中,赵老师带领你在WPF中,从零开始一步步构建MVVM模式,直到让你亲自以WPF+MVVM的方式,让这个经典的“记事本”软件从你的手中“复活”。在课程中,赵老师会详细讲解WPF和MVVM中的各种技巧,让你从此爱上WPF+MVVM编程。

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧