C错误C2040'f':'errno_t'的间接级别与'FILE *'不同

时间:2016-07-22 10:22:26

标签: c

任何帮助将不胜感激。我正在编写此代码但是我不断收到此错误,我不确定如何处理它。我在网上看过C2040,但它仍然无法解决我的问题。

#include "stdafx.h"
#include "stdlib.h"

struct Employer
{
char name[50];
int house;
int age;
};

int main()
{
struct Employer employee1;

printf("Employee information:\n\n");

printf("Please input your house number: ");
scanf_s("%d", &employee1.house);

printf("\n");

printf("Please enter your age: ");
scanf_s("%d", &employee1.age);

printf("Please input your name: ");
scanf_s("%s\n", &employee1.name, 50);

getchar();
getchar();

{
    FILE *f;
    errno_t f = fopen_s(&f, "Employee details.txt", "w");

    printf("Employees' name: %s", employee1.name);
    printf("Employees' house number: %d", employee1.house);
    printf("Employees' age: %d", employee1.age);
}
return(0);
}

1 个答案:

答案 0 :(得分:3)

您不能将名称f用于errno_t,因为您已将其用于FILE*

所以将errno_t f = fopen_s(....更改为errno_t error = fopen_s(....