{"id":4037,"date":"2021-06-23T22:16:59","date_gmt":"2021-06-23T14:16:59","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=4037"},"modified":"2021-06-23T22:16:59","modified_gmt":"2021-06-23T14:16:59","slug":"%e5%9d%91fread%e7%9a%84%e6%a8%a1%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=4037","title":{"rendered":"[\u5751]fread\u7684\u6a21\u5f0f"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>    FILE* fp = NULL;\n    char* buff = NULL;\n    fopen_s(&amp;fp, filename, \"r\");\n    if (fp != NULL)\n    {\n        fseek(fp, 0, SEEK_END);\n        long fileSize = ftell(fp);\n        fseek(fp, 0, SEEK_SET);\n        buff = (char*)malloc(fileSize + 1);\n        memset(buff, 0, fileSize + 1);\n        size_t rdsz = fread(buff, 1, fileSize, fp);\n        fclose(fp);\n        if (rdsz != fileSize)\n        {\n            \/\/ \u6b64\u5904\u8bfb\u6587\u672c\u6587\u4ef6\u4f1a\u62a5\u9519<\/code><\/pre>\n\n\n\n<p>\u5fc5\u987b\u8981\u4f7f\u7528<br>fopen_s(&amp;fp, filename, &#8220;rb&#8221;); \u7684\u4e8c\u8fdb\u5236\u6a21\u5f0f\u624d\u884c<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5fc5\u987b\u8981\u4f7f\u7528fopen_s(&amp;fp, filename, &#8220;rb&#8221;); \u7684\u4e8c\u8fdb\u5236 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/4037"}],"collection":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4037"}],"version-history":[{"count":1,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/4037\/revisions"}],"predecessor-version":[{"id":4038,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/4037\/revisions\/4038"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4037"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4037"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}