hi guys

I'm doing a c program to accept student details, store them, view,edit and 
print but i'm having problems in storing the details,viewing them,printing & 
navigating,through them,could any one help.the code is below

 #include<stdio.h>
 #include<conio.h>
 #include<string.h>
 #include<stdlib.h>
 #include<process.h>
 #include<graphics.h>
   struct  student
   {
   int stdid;
   char fname[20];
   char sname[30];
   char dob[10];
   char nid[20];
   char course[30];
   long int cell;
   char address[100];
   int olevel;
   }student;

FILE *ptf;
int setbackcolor;
void login();
void neww();
void view();
void edit();
void print();
void exit();
void menu();

void main()
 {
   clrscr();
   gotoxy(15,2);
   printf(" W E L C O M E    TO  T R U S T   S O F T W A R E");
   getch();

   login();
 }

void login()
  {
   char uname[4];
   char pass[2];
   int usr,pwd;

   clrscr();
  gotoxy(24,10);printf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿");
  gotoxy(24,11);printf("³           LOGIN             ³");
  gotoxy(24,12);printf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
  gotoxy(24,13);printf("³                             ³");
  gotoxy(24,14);printf("³ Username:[               ]  ³");
  gotoxy(24,15);printf("³                             ³");
  gotoxy(24,16);printf("³ Password:[               ]  ³");
  gotoxy(24,17);printf("³                             ³");
  gotoxy(24,18);printf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ");
   gotoxy(36,14);
   scanf("%s",&uname);
   usr=strcmp(uname,"admin");

   if (usr!=0)
      {
       gotoxy(36,14);
       printf("wrong username!");
       getch();
       login();
      }
   if (usr==0)
      {gotoxy(36,16);scanf("%s",&pass);
      pwd=strcmp(pass,"dmm");
      }
   if (pwd==0)

      {
       menu();
      }

    else
    if (pwd!=0)
      {
      gotoxy(36,16);printf("wrong password");
      getch();
      login();
      }
   }

void menu()
    {
     int choice;
     MenuStart:
     clrscr();

  gotoxy(25,10);printf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
  gotoxy(25,11);printf("º          MAIN MENU         º");
  gotoxy(25,12);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(25,13);printf("º          1.NEW             º");
  gotoxy(25,14);printf("º          2.VIEW            º");
  gotoxy(25,15);printf("º          3.EDIT            º");
  gotoxy(25,16);printf("º          4.PRINT           º");
  gotoxy(25,17);printf("º          5.EXIT            º");
  gotoxy(25,18);printf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");
  gotoxy(30,20);printf("Enter choice [ ] ");
  gotoxy(44,20);scanf("%d",&choice);

     switch (choice)
      {
       case 1:neww();break;
       case 2:view();break;
       case 3:edit();break;
       case 4:print();break;
       case 5:exit();break;
       }
      }
  void neww()
    {
   clrscr();
   ptf = fopen("students.dat","w+");
  
gotoxy(10,10);printf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
  gotoxy(10,11);printf("º                        STUDENT DETAILS                
      º");
  
gotoxy(10,12);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(10,13);printf("ºStudent Id:                     º  Course   :          
      º");
  
gotoxy(10,14);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(10,15);printf("ºName      :                     º  Cellphone:          
      º");
  
gotoxy(10,16);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(10,17);printf("ºSurname   :                     º  Address  :          
      º");
  
gotoxy(10,18);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(10,19);printf("ºD.O.B     :                     º  O levels :          
      º");
  
gotoxy(10,20);printf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");

   gotoxy(23,13);
   scanf("%d",&student.stdid);
   fprintf(ptf,"%d",student.stdid);
   gotoxy(23,15);
   scanf("%s",&student.fname);
   fprintf(ptf,"%s",student.fname);
   gotoxy(23,17);
   scanf("%s",&student.sname);
   fprintf(ptf,"%s",student.sname);
   gotoxy(23,19);
   scanf("%s",&student.dob);
   fprintf(ptf,"%s",student.dob);
   gotoxy(60,13);
   scanf("%s",&student.course);
   fprintf(ptf,"%s",student.course);
   gotoxy(60,15);
   scanf("%i",&student.cell);
   fprintf(ptf,"%i",student.cell);
   gotoxy(60,17);
   scanf("%s",&student.address);
   fprintf(ptf,"%s",student.address);
   gotoxy(60,19);
   scanf("%d",&student.olevel);
   fprintf(ptf,"%d",student.olevel);
   menu();
   fclose(ptf);
   }
   void view()
   {
    //void delet();
    //void next();
    //void prev();
    //void last();
    //void first();
    int resp;
    clrscr();
    ptf=fopen("student.dat","r+");

  
gotoxy(10,10);printf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
  gotoxy(10,11);printf("º                                   Search student Id:[ 
     ]º");
  
gotoxy(10,12);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(10,13);printf("º                                º                      
      º");
  
gotoxy(10,14);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(10,15);printf("º                                º                      
      º");
  
gotoxy(10,16);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(10,17);printf("º                                º                      
      º");
  gotoxy(10,18);printf("º                                º                      
      º");
  
gotoxy(10,19);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(10,20);printf("º                                º                      
      º");
  
gotoxy(10,21);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(10,22);printf("º 9.Delete          1.|<<   7.<<   6.>>   3.>>|         
      º");
  
gotoxy(10,23);printf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");
  gotoxy(15,24);printf("Enter navigation choice[ ]");
  switch(resp)
  {
   //case 9:delet();break;
   //case 1:first();break;
   //case 7:prev();break;
   //case 6:next();break;
   //case 3:last();break;
  }
   gotoxy(23,13);
   fscanf(ptf,"%d",&student.stdid);
   gotoxy(11,13);
   printf("Student Id is: %d",student.stdid);
   gotoxy(23,15);
   fscanf(ptf,"%s",&student.fname);
   gotoxy(11,15);
   printf("First name: %s",student.fname);
   gotoxy(23,17);
   fscanf(ptf,"%s",&student.sname);
   gotoxy(11,17);
   printf("Surname: %s",student.sname);
   gotoxy(23,19);
   fscanf(ptf,"%s",&student.dob);
   gotoxy(11,20);
   printf("Date of Birth: %s",student.dob);
   gotoxy(60,13);
   fscanf(ptf,"%s",&student.course);
   gotoxy(45,13);
   printf("Course: %s",student.course);
   gotoxy(60,15);
   fscanf(ptf,"%i",&student.cell);
   gotoxy(45,15);
   printf("Cellphone: %i",student.cell);
   gotoxy(60,17);
   fscanf(ptf,"%s",&student.address);
   gotoxy(45,17);
   printf("Address: %s",student.address);
   gotoxy(60,19);
   fscanf(ptf,"%d",&student.olevel);
   gotoxy(45,20);
   printf("'O' levels passed: %d",student.olevel);
   getch();
   menu();
   fclose(ptf);
  }
   void edit()
   { int resp;
     clrscr();
     ptf=fopen("student.dat","a+");

  
gotoxy(10,10);printf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
  gotoxy(10,11);printf("º                                   Search student Id:[ 
     ]º");
  
gotoxy(10,12);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(10,13);printf("º                                º                      
      º");
  
gotoxy(10,14);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(10,15);printf("º                                º                      
      º");
  
gotoxy(10,16);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(10,17);printf("º                                º                      
      º");
  gotoxy(10,18);printf("º                                º                      
      º");
  
gotoxy(10,19);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(10,20);printf("º                                º                      
      º");
  
gotoxy(10,21);printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
  gotoxy(10,22);printf("º 9.Delete          1.|<<   7.<<   6.>>   3.>>|         
      º");
  
gotoxy(10,23);printf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");
  gotoxy(15,24);printf("Enter navigation choice[ ]");
  switch(resp)
  {
   //case 9:delet();break;
   //case 1:first();break;
   //case 7:prev();break;
   //case 6:next();break;
   //case 3:last();break;
  }
   gotoxy(23,13);
   fscanf(ptf,"%d",&student.stdid);
   gotoxy(11,13);
   printf("Student Id is:%d",student.stdid);
   gotoxy(23,15);
   fscanf(ptf,"%s",&student.fname);
   gotoxy(11,15);
   printf("First name: %s",student.fname);
   gotoxy(23,17);
   fscanf(ptf,"%s",&student.sname);
   gotoxy(11,17);
   printf("Surname: %s",student.sname);
   gotoxy(23,19);
   fscanf(ptf,"%s",&student.dob);
   gotoxy(11,20);
   printf("Date of Birth: %s",student.dob);
   gotoxy(60,13);
   fscanf(ptf,"%s",&student.course);
   gotoxy(45,13);
   printf("Course: %s",student.course);
   gotoxy(60,15);
   fscanf(ptf,"%i",&student.cell);
   gotoxy(45,15);
   printf("Cellphone: %i",student.cell);
   gotoxy(60,17);
   fscanf(ptf,"%s",&student.address);
   gotoxy(45,17);
   printf("Address: %s",student.address);
   gotoxy(60,19);
   fscanf(ptf,"%d",&student.olevel);
   gotoxy(45,20);
   printf("'O' levels passed: %d",student.olevel);
   getch();
   fclose(ptf);
   }
   void print()
   {
   }
   void exit()
   {
    int status=0;

     exit(status);
   }







[Non-text portions of this message have been removed]

Reply via email to