有点搞不懂freopen

tianxiaogang12 2006-05-21 10:27:23
请大侠帮我讲讲
freopen("input.txt", "r", stdin);
中的stdin的意思 且用在这有什么用 感谢
...全文
124 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
hslinux 2006-05-29
  • 打赏
  • 举报
回复
<stdio.h>:

FILE *stdin;

FILE *stdout;

FILE *stderr;

stdin Standard input
stdout Standard output
stderr Standard error
tatbaby 2006-05-29
  • 打赏
  • 举报
回复
The freopen function closes the file currently associated with stream and reassigns stream to the file specified by path.

stdin 标准输入流,接受来自键盘的输入
FILE *finfreopen("input.txt", "r", stdin);
/*输入来自文件input.txt,而非键盘输入;只读方式;*/
在这里,此句关闭了当前的键盘输入流stdin,并且将输入流重新赋值为指定的input.txt。

tatbaby 2006-05-29
  • 打赏
  • 举报
回复
FILE *freopen(
const char *path,
const char *mode,
FILE *stream
);

Parameters
path
Path of new file.
mode
Type of access permitted.
stream
Pointer to FILE structure.
Return Value
Each of these functions returns a pointer to the newly opened file. If an error occurs, the original file is closed and the function returns a NULL pointer value.
nadirboxer 2006-05-28
  • 打赏
  • 举报
回复
stdin就是标准输入流
键盘输入
tianxiaogang12 2006-05-21
  • 打赏
  • 举报
回复
还有就是 freopen("input.txt", "r", stdin);
返回的是什么 啊 虽然说是返回的file指针
但还是不太清楚啊

65,187

社区成员

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

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