美文网首页
在 xCode 下面用 C 语言 fopen()函数相对路径

在 xCode 下面用 C 语言 fopen()函数相对路径

作者: Nulll | 来源:发表于2018-12-07 18:10 被阅读24次

product->scheme->edit scheme->Run->options->把 using custom working directory前面的勾选上。然后填写相对路径及可以。。下图

屏幕快照 2018-12-07 下午6.08.42.png
    // 然后这样写就好了
    char filePath[] = "./CFileDemo/testJson.json";
    FILE *file = fopen(filePath, "r+");
    if (file == NULL) {
        printf("testJson 打开失败, errno = %d; \n",errno);
    } else {

    }

// 起初我以为iOS里面bundle也可以 这样用,但事实是bundle里面的数据只有读取的权限,要沙盒里面的文件才可以有读取和写入权限,

C的书

推荐: http://book.douban.com/subject/1230004/
还可以用: http://c.learncodethehardway.org/book/ 这个当参考和练习

相关文章

网友评论

      本文标题:在 xCode 下面用 C 语言 fopen()函数相对路径

      本文链接:https://www.haomeiwen.com/subject/splxhqtx.html