Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

read and write binary in c

$
0
0

assume that the parameters have data of strings and integers that are in a structure with typedef

my function crashes when I added the fread function.

void save_question(type_tag *easy,type_tag *med,type_tag *diff,type_tag *bonus,int ind){
	FILE *fl;
	type_tag *test;
	if(ind==0){
	    fl=fopen("SAVED EASY QUESTIONS.dat","wb");
		fwrite(&easy,sizeof(type_tag),1,fl);
		fclose(fl);
		fl=fopen("SAVED MEDIUM QUESTIONS.dat","wb");
		fwrite(&med,sizeof(type_tag),1,fl);
		fclose(fl);
		fl=fopen("SAVED DIFFICULT QUESTIONS.dat","wb");
		fwrite(&diff,sizeof(type_tag),1,fl);
		fclose(fl);
		fl=fopen("SAVED EASY QUESTIONS.dat","rb");
		fread(&test,sizeof(type_tag),1,fl);
	    fclose(fl);
	    getch();	
	}
}




Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>