gpt4 book ai didi

c - 尝试用 C 语言打开文件时出错

转载 作者:行者123 更新时间:2023-11-30 20:33:01 25 4
gpt4 key购买 nike

我刚刚开始学习 C,在尝试运行一个简单的程序来打开 .txt 文件时遇到了此错误。

Sublime text editor code

MAC Terminal

最佳答案

在尝试遍历文件之前,测试 fopen() 返回的指针:

if(!pToFile) // or if(pToFile == NULL) 
exit(1); //exit the program

关于c - 尝试用 C 语言打开文件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46397801/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com