c++怎么创建文件但不输入?

qq_55523369 2021-02-24 11:13:59
c++怎么创建文件但不输入?,各位大侠指导一下
...全文
182 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
熊猫呀 2021-02-26
  • 打赏
  • 举报
回复
引用 11 楼 把海弄干的鱼歌者 的回复:
不是C++吗?你们为什么用C的fopen函数?不应该用fstream类吗?
虽然我是写c++ 的 但是 我几乎没用过 fstream。。。。。
qq_55523369 2021-02-26
  • 打赏
  • 举报
回复
但是也可以亚
熊猫呀 2021-02-25
  • 打赏
  • 举报
回复
引用 8 楼 qq_55523369 的回复:
[quote=引用 7 楼 qq_55523369 的回复:][quote=引用 4 楼 熊猫呀 的回复:][quote=引用 3 楼 qq_55523369 的回复:]好的谢谢,就是fclose(pFile);要吗?
要的 打开文件 和 关闭 文件 应该成对出现[/quote] 但是它是这样的 8 52 C:\Users\86138\Desktop\c++\60mainanzhuanhg.cpp [Error] too few arguments to function 'FILE* freopen(const char*, const char*, FILE*)' 12 0 D:\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include\locale.h In file included from D:/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include/locale.h 42 D:\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\clocale from D:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/clocale 40 D:\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\x86_64-w64-mingw32\bits\stdc++.h from D:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/x86_64-w64-mingw32/bits/stdc++.h 1 C:\Users\86138\Desktop\c++\60mainanzhuanhg.cpp from C:\Users\86138\Desktop\c++\60mainanzhuanhg.cpp 455 17 D:\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include\stdio.h [Note] declared here[/quote] 我代码是这样的 #include<bits/stdc++.h> #include<windows.h> using namespace std; int main() { system("md D:\\60(1)"); Sleep(100); FILE*pFile =freopen("D:60(1):\\60mscyhsj.txt","wb"); fclose(pFile); }[/quote] fopen 不是 freopen
qq_55523369 2021-02-25
  • 打赏
  • 举报
回复
引用 7 楼 qq_55523369 的回复:
[quote=引用 4 楼 熊猫呀 的回复:][quote=引用 3 楼 qq_55523369 的回复:]好的谢谢,就是fclose(pFile);要吗?
要的 打开文件 和 关闭 文件 应该成对出现[/quote] 但是它是这样的 8 52 C:\Users\86138\Desktop\c++\60mainanzhuanhg.cpp [Error] too few arguments to function 'FILE* freopen(const char*, const char*, FILE*)' 12 0 D:\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include\locale.h In file included from D:/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include/locale.h 42 D:\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\clocale from D:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/clocale 40 D:\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\x86_64-w64-mingw32\bits\stdc++.h from D:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/x86_64-w64-mingw32/bits/stdc++.h 1 C:\Users\86138\Desktop\c++\60mainanzhuanhg.cpp from C:\Users\86138\Desktop\c++\60mainanzhuanhg.cpp 455 17 D:\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include\stdio.h [Note] declared here[/quote] 我代码是这样的 #include<bits/stdc++.h> #include<windows.h> using namespace std; int main() { system("md D:\\60(1)"); Sleep(100); FILE*pFile =freopen("D:60(1):\\60mscyhsj.txt","wb"); fclose(pFile); }
qq_55523369 2021-02-25
  • 打赏
  • 举报
回复
引用 4 楼 熊猫呀 的回复:
[quote=引用 3 楼 qq_55523369 的回复:]好的谢谢,就是fclose(pFile);要吗?
要的 打开文件 和 关闭 文件 应该成对出现[/quote] 但是它是这样的 8 52 C:\Users\86138\Desktop\c++\60mainanzhuanhg.cpp [Error] too few arguments to function 'FILE* freopen(const char*, const char*, FILE*)' 12 0 D:\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include\locale.h In file included from D:/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include/locale.h 42 D:\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\clocale from D:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/clocale 40 D:\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\x86_64-w64-mingw32\bits\stdc++.h from D:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/x86_64-w64-mingw32/bits/stdc++.h 1 C:\Users\86138\Desktop\c++\60mainanzhuanhg.cpp from C:\Users\86138\Desktop\c++\60mainanzhuanhg.cpp 455 17 D:\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include\stdio.h [Note] declared here
qq_55523369 2021-02-25
  • 打赏
  • 举报
回复
引用 3 楼 qq_55523369 的回复:
好的谢谢,就是fclose(pFile);要吗?
xian0-666 2021-02-25
  • 打赏
  • 举报
回复
任何带创建新文件的方式打开,再关闭就行了
熊猫呀 2021-02-25
  • 打赏
  • 举报
回复
引用 3 楼 qq_55523369 的回复:
好的谢谢,就是fclose(pFile);要吗?
要的 打开文件 和 关闭 文件 应该成对出现
[PE]经典八炮 2021-02-25
  • 打赏
  • 举报
回复
不是C++吗?你们为什么用C的fopen函数?不应该用fstream类吗?
qq_55523369 2021-02-25
  • 打赏
  • 举报
回复
哦,ok谢谢
熊猫呀 2021-02-24
  • 打赏
  • 举报
回复
FILE * pFile = fopen("xxxx","wb"); fclose(pFile );
qq_55523369 2021-02-24
  • 打赏
  • 举报
回复
好的谢谢,就是fclose(pFile);要吗?
NorZ 2021-02-24
  • 打赏
  • 举报
回复
https://blog.csdn.net/hcf999/article/details/77864456 随便找了一下

64,646

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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