struct Product{
	/* declare variables here to store product data */
	char product_name[LEN];
	int product_id;
	int quantity;
	double unit_price;
	int expire_month, expire_year;
	struct Product *next;
};

pfile=fopen("binary.bin","wb");
if(pfile!=NULL)
{
	while(head != NULL)
	{
		fwrite(&head, sizeof(struct Product), 1, pfile);
		//head=head->next;
	}
	fclose(pfile);
	puts("File Saved successfully!");
	system("pause");
}	
else
{
	puts("File not found");
	system("pause");
}

pls help ,i cant get it working..

Try fwrite(head

Note that you're writing pointers (in the next field) directly out to disk. You need to make sure that you ignore this field when you next read the file into memory, because those pointers will be meaningless.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.