Hello all.
I have made a attendance cum database management system.
however when i choose the display all records option for the first time or without choosing the take attendance option, i get the output which treats every single character as an independent record.
Here is the code :

Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>

struct student
{
char nm[20],rl[10];
int i;
};
struct student d;

void main()
{

	int ptr,ptr1,x,i;
	long int recsize;
	FILE *fp;
	char b,j,w,user[10],cnf[6]={'q','w','e','r','t','y'},cpwd[6]={'q','w','e','r','t','y'},roll[10],pwd[6],another,qwe[20];
   fflush(stdin);
	again:
		clrscr();
      gotoxy(23,10);
  		printf("Enter UserName : ");
		//gets(user);
      gotoxy(23,11);
		printf("Enter Password : ");
      fflush(stdin);
      //for(i=0;i<=5;i++)
		//{
        // pwd[i]=getch();
    		//putch('*');
		//}
      //getch();
		ptr= strcmp(user,cnf);
      ptr1= strcmp(pwd,cpwd);
      //printf("%d",ptr);
      //getch();
  	//if(ptr==0&&ptr1==0)
	{
	repeat:
	clrscr();
	printf("\n********** Welcome to ADMS v 1.0 **********\n\n\n\nPlease select your option:\n\n\n1. Take Attendance\n2. Add students to the Database\n3. List All the records\n4. Delete All Records\n5. Exit\n\n\n Please Enter your option : ");
   fflush(stdin);
	j=getchar();
		if(j=='1')
		{
		clrscr();
		printf("\n\nUsing this option, you can take attendance of the students whose records\nare present in the database.\n\n1. Press 1 to take attendance.\n2. Press any other key to go back to main menu.");
		fflush(stdin);
		b=getche();
			if(b=='1')
			{

				recsize=sizeof(d);
            if((fp=fopen("123.txt","r+"))!=NULL)
					{
						printf("\n\nEnter the Roll.No. :");
						fflush(stdin);
						scanf("%s",roll);
						rewind(fp);
                  while(fread(&d,recsize,1,fp)==1)
							{

								if(strcmp(d.rl,roll)==0)
									{
                              x=d.i;
										x++;
										d.i=x;
										fseek(fp,-recsize,SEEK_CUR);
										fwrite(&d,recsize,1,fp);
                              printf("\nAttendance Taken.\n\nCurrent Attendance of %s is : %d ",d.nm,d.i);
										getch();
                              fclose(fp);
                              break;
                           }

                     }
					goto repeat;
					}
            else
               {

               		printf("\n\nFile couldn't be opened or it doesn't exists. Please create a new file by using option 2 from main menu.\n\n press any key to go back to main menu.");
               		getch();
                     goto repeat;
               }
         }
         else goto repeat;
	   }


   	else if(j=='2')
	   {
		clrscr();

		printf("\n\nUse this option to add the data\nof the students present in the database.\n\n=> Press 1 to make additions.\n\n  Press any other key to return to main menu.");
		b=getche();
		if(b=='1')
				{
					clrscr();
					another='y';
               fp=fopen("123.txt","a+");
               if(fp!=NULL)
               {
               	while(another=='y')
						{
                     label1:
							printf("\nEnter Roll.No : ");
                     fflush(stdin);
							gets(d.rl);
                     strcpy(qwe,d.rl);
                     rewind(fp);
                     while(fread(&d,sizeof(d),1,fp)==1)
                     {

                       if(strcmp(qwe,d.rl)==0)
                       {
                       printf("\n\nRE !");

                       getch();
                       goto label1;
                       break;
                       }
                       //break;
                     }
                     //getch();
                     strcpy(d.rl,qwe);
                  	fflush(stdin);
                  	printf("Enter Name : ");
                     gets(d.nm);
							d.i=0;
                     fseek(fp,sizeof(d),SEEK_END);
							fwrite(&d,sizeof(d),1,fp);
                     printf("\nAdd another record(y/n) : ");
							fflush(stdin);
							another=getche();
                     if(another=='n')
                     break;
						}
               }

               else
               {
               printf("File can't be opened or doesn't exists !");
               getch();
               goto repeat;
               }
		  		   fclose(fp);
			      if(another=='n')
			      goto repeat;


			   }
		else goto repeat;

	   }

	   else if(j=='3')
	   {

        fflush(stdin);


         if((fp=fopen("123.txt","r"))!=NULL)
            {


               rewind(fp);

      			while(fread(&d,recsize,1,fp)==1)
					printf("\n\nRoll No. %s %s has attended %d lectures.",d.rl,d.nm,d.i);
					getch();
               fclose(fp);

					goto repeat;
            }
         else
       		{
                fflush(stdin);
      			 printf("\n\nFile couldn't be opened !");
                getch();
                goto repeat;
            }
	   }


      else if(j=='4')
	   {
		  printf("\n\nAre you sure you want to delete the whole record ? (y/n) : ");
        fflush(stdin);
        w=getchar();
        if(w=='y')
        	{
            fclose(fp);
         	remove("123.txt");
            printf("\n\nFile Deleted !!!");
            getch();
            goto repeat;
	      }
        else
        goto repeat;
      }

      else if(j=='5')
	   {
		  printf("\n\nHave a nice day !!\n\nPress any key to exit.");
		  getch();
		  exit(0);
    	}


	   else
	   {
		   printf("\n\nIncorrect option entered, press any key to try again.");
		   getch();
		   goto repeat;
	   }
   }

//else
//goto repeat;

}
Check out the program by creating a file and then displaying the records first of all after starting afresh i.e. closing and opening the program again. Then take attendance of some record and then display the file and you will get the correct format.

Thanks for your help !

Ish2rock