I find this code in a website:
struct person
{
int id;
char fname[20];
char lname[20];
};
int main ()
{
FILE *outfile;
// open file for writing
outfile = fopen ("person.dat", "w");
struct person input1 = {1, "rohan", "sharma"};
// write struct to file
fwrite (&input1, sizeof(struct person), 1, outfile);
if(fwrite != 0)
printf("contents to file written successfully !\n");
return 0;
}
- Is line
if(fwrite != 0)
correct? - Does we can compare function name itself(
fwrite
)? - What is value of
fwrite
in this case?