m0_62801663 2022-05-18 16:39 采纳率: 72%
浏览 54
已结题

C语言文件读取问题如何解决

在C语言中怎样正常加载磁盘文件,请用一段简短的文字来进行描述

  • 写回答

1条回答 默认 最新

  • SoporAeternus2022 2022-05-19 17:47
    关注

    https://cplusplus.com/reference/cstdio/fopen/

    fopen
    FILE * fopen ( const char * filename, const char * mode );
    Open file
    Opens the file whose name is specified in the parameter filename and associates it with a stream that can be identified in future operations by the FILE pointer returned.
    The operations that are allowed on the stream and how these are performed are defined by the mode parameter.
    The returned stream is fully buffered by default if it is known to not refer to an interactive device (see setbuf).
    The returned pointer can be disassociated from the file by calling fclose or freopen. All opened files are automatically closed on normal program termination.
    The running environment supports at least FOPEN_MAX files open simultaneously.

    打开文件
    打开其名称在参数文件名中指定的文件,并将其与一个流相关联,该流可以在以后的操作中通过返回的 FILE 指针来标识。
    流上允许的操作以及如何执行这些操作由 mode 参数定义。
    如果已知返回的流不引用交互式设备(请参阅 setbuf),则默认情况下返回的流是完全缓冲的。
    返回的指针可以通过调用 fclose 或 freopen 与文件解除关联。 所有打开的文件都会在程序正常终止时自动关闭。
    运行环境至少支持同时打开 FOPEN_MAX 个文件。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 6月20日
  • 已采纳回答 6月20日
  • 创建了问题 5月18日