fprintf_s如何用?fprintf会被提示安全漏洞。

代码如下 并不会有任何东西写出来

 i=0;
    counts=0;
    FILE *ofile;
    errno_t oerr;
    oerr = fopen_s(&ofile,"E:\\workspace\\TVPLAY\\data\\test\\test2.txt","w");
    if(oerr!=0)
    {       
        cout<<"could not open the file";            
        exit(EXIT_FAILURE); 
    }
    for (int i = 0; i < sizeof(data); i++)
    {
        if(fprintf_s(ofile,"%d",(int *)&data[i])<0)
        {
            break;
        }
        i++;
        counts++;

    }

基础不牢,用什么都可能成漏洞的啊。data 什么定义啊

fprintf_s是新版本的,fprintf是老的,在vc6里面用不会提示

搞定了,(int *)&data[i]) 是我读字符时候转char为int 写出去不要了

http://blog.163.com/jdxxf@126/blog/static/141007095201031283334972/