I\'m using a struct and array of functions, but the main thing is I don\'t know
ID: 3657910 • Letter: I
Question
I'm using a struct and array of functions, but the main thing is I don't know how to write the information to an output.txt file. I use this and there's jumbled up stuff in the file and not the actual words of what is in my program.
void SaveInvent(bball br[], int *size)
FILE *infile;
if((infile = fopen("output.txt","w"))==0)
{
printf(" CANNOT OPEN FILE ");
return;
}
//connect to the file
infile= fopen("output.txt","w");
fprintf(infile,"%d", *size);
fwrite(br, sizeof(books),*size,infile);
//close file pointer
fclose(infile);
}
Program says that's wrong
Explanation / Answer
///LOOK AT THE BELOW CODE #include #include void main() { FILE *fp; char str1, str2, str3; clrscr(); if ((fp = fopen("tryme","r"))==NULL) { printf("Cannot open file "); } fscanf(fp,"%s %s %s",str1, str2, str3); fprintf(stdout, "%s %s %s",str1,str2,str3); fclose(fp); getch(); }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.