Hi all,
I've just learned how to create files in C, and I have an entire program written for an inventory. The code compiles and runs, the problem is that the file that I have created won't open within the program. The function prototype that initializes the file is below:
So my questions is, what is the best way to create a file, then use it in the program itself?Code:void initialize(void)
{
int i;
struct inventory blanklist = { 0, "", 0, 0.0};
FILE *cfptr;
if((cfptr = fopen("harware.dat", "wb+")) == NULL){
printf("File could not be found");
}
else{
for(i = 1; i <= 100; i++){
fwrite(&blanklist, sizeof(struct inventory), 1, cfptr);
}
}
}