this is just part of my program the problem are when the program asks user to put code if the user puts nothing just press enter. the program should go to ShowData() and show all records in Manufacterer.txt in A : drive but it doesn't show all of record inside that file
the second problem is variable calls 'position' . it works as an index so if there are 5 records in Manufacterer.txt when the user puts the new record. the position should be 5. it uses fread doesn't it? but i don't know how to find the last position in the file.

sorry i am very new with C
thanks very much for helping
Code:
#include <stdio.h>
//#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include <math.h>

void ShowData();
	struct Manufacturer //creating your own data type
	{
		char code[6],name[16], address[21],contact[11];//63 type long
		int position;
		bool pass;
	};
  main(void)
{
	long offset;
	int test;
	struct Manufacturer m;
	m.pass=true;
FILE *f;
	f=fopen("a:\\Manufacturer.txt","ab");//"w" c

	puts("Enter code:");
	gets(m.code);
	fflush(stdin);
	printf("%d",test);
 	while (strlen(m.code)>0)
 	{
 
		
			puts("Enter name:");
			gets(m.name);
			
			puts("Enter Address: ");
			gets(m.address);
			
		
			puts("Enter contact");
			gets(m.contact);
			m.position;
			fwrite(&m, sizeof(m),1,f);
			
   	
   		puts("Enter code");
   		gets(m.code);
   		m.position=m.position+1;
   	
}
	;
fclose(f);

ShowData();
}
	void ShowData()
	{
	struct Manufacturer ma;
	int count = 1;
	FILE *f;

	
	f=fopen("a:\\Manufacturer.txt","r+");
		
		while (fread(&ma,sizeof(ma),1,f)==1)
	{
		printf("Show");
		printf("Record %d\n",count++);
		puts(ma.code);
		puts(ma.name);
		puts(ma.address);
		puts(ma.contact);
		puts(ma.position);
		printf("inside");
	}
	fclose(f);
	}