关于 fopen_s的用法


在最新的vs中已经不能使用 fopen 必须使用 fopen_s函数

基本的使用方法是

#include<stdio.h>

int main()
{
    FILE* fp;
    // errno_t == int ,也就是 typedef int errn_t
    errno_t error;
    error = fopen_s(&fp, "C:\\users\\mike1\\desktop\\mm.txt", "w+");
    //这里的返回值是,如果成功返回0,如果不成功返回非0
    if (error != 0 )
    {
        printf("打开失败");
    }

    char name[] = "你好,师姐。";
    fwrite(name, 1, sizeof(name), fp);
    fclose(fp);
    return 0;
}

不知为什么  C:\\mm.txt  这么写就找不到文件

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM