Visual Studio C ++中的fopen_s问题

时间:2018-04-24 08:44:47

标签: c++ visual-studio-2015

我在Visual Studio 2015中为C ++做了一项任务,在尝试打开文件读取值时,我一直收到stream != nulltpr错误或stream.valid()错误。我的代码有问题吗?

#include "stdafx.h"

FILE *data;

int main(void)
{
    errno_t err;

    err = fopen_s(&data, "input.txt", "r");                                     

    if (err == 0) {                                                                  
        printf_s("the file was opened");                                    
    }
    else {
        printf_s("error, input file not opened\n"); 
    }

    return 0;
}

0 个答案:

没有答案