Code:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
typedef struct
{
        int account_number;
        char account_type[30];
        int balance;
}account;
void main()
{
        struct account acc[5];
        int i;
        for(i=0;i<5;i++)
        {
                printf("Enter Account Number : ");
                scanf("%d",&acc[i].account_number);
                printf("Enter Account Type : ");
                fflush(stdin);
                gets(acc[i].account_type);
                printf("Enter Balance : ");
                scanf("%d",&acc[i].balance);
        }

        FILE *ofp;
		for (i=0;i<5;i++)
		{
			printf("%d \n",acc[i].account_number);
			printf("%s \n",&acc[i].account_type);
			printf("%d \n",acc[i].balance);
			ofp = fopen("customer.txt", "wb");
			fwrite(&acc[i], sizeof acc[i], 5, ofp);
		}
	
		fclose(ofp);

        system("cls");
printf("Account with balance higher then Rs.500/-");
        printf("******************************************\n");

        for(i=0;i<5;i++)
        {
        	if(acc[i].balance>500)
        	{
	        	printf("Record no. %d \n\n",i);
        		printf("Account Number : ");
         		printf("%d \n",&acc[i].account_number);
          		printf("Account Type : ");
          	 	printf("%s \n",&acc[i].account_type);
          		printf("Balance : ");
          	 	printf("Rs.%d \n",&acc[i].balance);
          	 	printf("\n\n");
	        }    	
        }
}
this is all i could do...the struct is not written in the txt file... there must be some mistake...
and actually the second output printing is to be done by reading the values from the txt file..but i have directly printed it..

Last edited by shabbir; 10Oct2012 at 22:24.. Reason: Code blocks