URGENT! Menu driven & records handling

This is a discussion on URGENT! Menu driven & records handling within the C Programming forums, part of the General Programming Boards category; PHP Code: --  Please help me out .  I have spent 48hrs nonstop trying to get my this set of programs to work .  I have to submit my project on 18 - 19 this NOV .  --  Basically i want to create a  list  of menu driven screens allowing the user to navigate through them :  allowing him to create / add ,  ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    1

    URGENT! Menu driven & records handling

    PHP Code:
    -- Please help me outI have spent 48hrs nonstop trying to get my this set of programs to workI have to submit my project on 18-19 this NOV

    -- 
    Basically i want to create a list of menu driven screens allowing the user to navigate through themallowing him to create/adddelete and seek and display list of members and films rented by a video club.

    -- 
    I have created the screens and a screen allowing member to be added to a file(memberz.datbut can't work around to delete a record and list them.

    -- Neither i can coordinate them to work all together. Plzzz help me. This course work will allow me to pass my whole diploma level.

    --Have been borrowing bits and pieces from diff. programs. They do work. I also need to enter a current fee charged for hiring a film and calculate any outstanding fee.

    I am confused and stucked no way i'
    ll be able to completeJust have to scroll up and down the screen for daysWell here is what i have doneI would be very grateful to all you pplPlzzzz help me outi have had loads of sample code but can't get them working after modify. 

    I am using Turbo C++ 3.1 to run them.

    here are programs: 
    ---------------------------------------------------------------------------------
    Code:
    /* Program Name	: mainmenu.cpp
       Date 	                : 08-Nov-05
       Written By	: Ramtohul Ravin
       Purpose	: Designing a Member Layout Screen 
    */
    
    #include <stdio.h>
    #include <string.h>
    #include <conio.h>
    #include <stdlib.h>
    
    #include "memmenu.h"
    
    char menu(void);
    void backup(void);
    
    // MAIN MENU OPTIONS LISTING
    
    char menu(void)
    
    {
       char optrtn;
    
       	clrscr();
    	drawscreen1();
    
    	gotoxy(29,9);
    	printf("* * * MAIN MENU * * *");
          
       	gotoxy(10,13);
    	printf("MEMBERS.............................1 ");
    
    	gotoxy(10,15);
    	printf("FILMS & MOVIES......................2 ");
    
    	gotoxy(10,17);
    	printf("UTILITY.............................3 ");
    
    	gotoxy(10,19);
            printf("EXIT................................4 ");
    
       gotoxy(10,23);
       printf(" PLEASE ENTER YOUR CHOICE [1.2.3.4]: ");
       optrtn = getch();
       return optrtn;
    }
    
    // CHOICES & CASES DEFINITIONS
    
    void main(void)
    
    {
    char option,exit_opt;  /* menu and exit option*/
    char mem_opt, mov_opt;
    char back_opt;
    
    /* MAIN MENU */
     do
      {
       do
        {
         option = menu();
    
          if (option == '1')  // Members Main Menu
           {
    	member();
    	getch();
           }
    
          else
           if (option == '2') // Movies Main Menu
    	   {
    	    movie();
                getch();
    	   }
    
          else
    	if (option == '3') // Utility BackUp
           {
    	 clrscr();
             drawscreen1();
    	 gotoxy(20,15);
    	 printf("DO YOU WANT TO SAVE THE DETAILS YOU ENTERED?\n\n");
    	 printf("Press 'Y' To CONFIRM, Any Other Key To CANCEL");
    	 back_opt = getch();
    	 flushall();
    
    	 if (back_opt == 'y' || back_opt =='Y')
               {
    	    clrscr();
    	    backup();
    	   }        
            }
    
         else
           if (option == '4') /* exit option */
           {
    	  gotoxy(3,25);
    	  printf("SURE TO QUIT?, Press 'Y' To Confirm OR Anykey To Cancel");
    	  exit_opt = getch();
    	  flushall();
    
    	if (exit_opt == 'y' || exit_opt == 'Y')
    
         	 {
    	  clrscr();
    	  drawscreen1();
    	  gotoxy(3,4);
    	  printf(">> Exit To system <<\n\n");
    	  exitmenu();
    	 }
           }
    
         else /* user presses an invalid key display msg error */
          {
            gotoxy(3,25);
    	printf("Error: Invalid Keypress! Select An Option Between 1 and 4");
    	getch();
    	flushall(); /* clears buffer */
          }
       }
       while  (option > '4' || option < '1' );
     }
     while (option != '`'); /* unlimated loop */
    }
    
    /***************************************************SAVING & BACKING UP THE ENTRIES TO A FILENAME
    ***************************************************/
    
    void backup(void)
    
          {
    	char filename[20];
    	char save_opt;
    	int k;
    
    	FILE *fpt;
    
    	{
             gotoxy(1,8);
    	 printf("Please Enter the path and filename to save to:");
    	 gotoxy(1,10);
    	 printf("Example: c:\\mydbfile.txt");
    	 gotoxy(48,8); /* move cursor back to line 8 */
    	 gets(filename);
    	 flushall();
    	 fpt = fopen (filename,"a"); /*open file for appending mode */
    
         if (fpt== NULL)
    
             {
    	   gotoxy(1,12);
    	   fprintf(stderr, "Error opening file %s.",filename);
    	   gotoxy(1,25);
    	   printf("Database was not saved!");
    	   getch();
    	   exit;
    	 }
    
            }
           }
    ---------------------------------------------------------------------------------
    HEADER FILE
    ---------------------------------------------------------------------------------
    Code:
    // Program Name	: Memmenu.h
    // Written by	: Ravin
    // Date		: 15-Nov-05
    
    #include <stdio.h>
    #include <string.h>
    #include <conio.h>
    #include <stdlib.h>
    
    #include "screeen.h"
    
    #define TRUE 1
    
    char member(void);
    char movie(void);
    
    // MEMBERS MAIN MENU OPTIONS LISTING
    
    char member(void)
    
      {
            char optrtn;
    
    	clrscr();
    	drawscreen1();
    
    	gotoxy(24,9);
    	printf("* * * MARINA MEMBERS MENU * * *");
          
       	gotoxy(10,13);
    	printf("ADD NEW MEMBERS.....................1 ");
    
    	gotoxy(10,15);
    	printf("DELETE EXISTING MEMBERS.............2 ");
    
    	gotoxy(10,17);
    	printf("LIST THEM ALL.......................3 ");
    
    	gotoxy(10,19);
    	printf("EXIT................................4 ");
    
          gotoxy(10,23);
          printf(" PLEASE ENTER YOUR CHOICE [1.2.3.4]: ");
          optrtn = getch();
          return optrtn;
      }
    
    // CHOICES & CASES DEFINITIONS
    
    /***************************************************
    	ADDING & CREATING NEW MEMBERS & SET UP NEW DATABASE
    **************************************************/
    
    // FILMS MAIN MENU OPTION LISTING
    
    char movie(void)
    
      {
            char optrtn;
    
    	clrscr();
    	drawscreen1();
    
    	gotoxy(24,9);
    	printf("* * * MARINA MOVIES MENU * * *");
          
       	gotoxy(10,13);
    	printf("ADD NEW MOVIES.....................1 ");
    
    	gotoxy(10,15);
    	printf("DELETE EXISTING MOVIES.............2 ");
    
    	gotoxy(10,17);
    	printf("LIST ALL MOVIES....................3 ");
    
    	gotoxy(10,19);
    	printf("EXIT...............................4 ");
    
    	gotoxy(10,23);
            printf(" PLEASE ENTER YOUR CHOICE [1.2.3.4]: ");
            optrtn = getch();
            return optrtn;
      }
    ---------------------------------------------------------------------------------
    THIS ONE WORKS FINE
    ---------------------------------------------------------------------------------
    Code:
    //Program Name	: screeen.h
    //Written By	: Ravin RAMTOHUL
    //Date		:15-11-2005
    
    #include <stdio.h>
    #include <string.h>
    #include <conio.h>
    #include <stdlib.h>
    #include <dos.h>
    
    void drawscreen1(void);
    void drawscreen2(void);
    void exitmenu(void);
    
    //CREATES THE SCREEN LAYOUT FOR MAIN MENU
    
    void drawscreen1(void)
    
    {
       struct date d;
    
       clrscr();
    
       gotoxy(25,2);
       printf ("*** THE MARINA MOVIE CLUB ***");
    
       gotoxy(27,4);
       printf(" NORTHOLT MARINA BRANCH ");
    
       gotoxy(5,8);
       printf("---------------------------------------------------------------------");
    
       gotoxy(5,10);
       printf("---------------------------------------------------------------------");
    
       /* getdate example */
             gotoxy(25,6);
    	 getdate(&d);
    	 printf("TODAY WE'RE ON THE : %d-%d-%d", d.da_day, d.da_mon, d.da_year);
        
    }
    
    // CREATES THE SCREEN LAYOUT FOR SUB MENUS FROM MAIN MENU
    
    void drawscreen2(void)
    
    {
    
     struct date d;
    
     clrscr();
    
         /* getdate example */
    	 gotoxy(20,7);
             getdate(&d);
             printf("TODAY WE'RE ON THE : %d-%d-%d", d.da_day, d.da_mon, d.da_year);
        
    
         gotoxy(25,2);
         printf(" THE MARINA MOVIE CLUB ");
         gotoxy(25,3);
         printf(" NORTHOLT MARINA BRANCH ");
    
    }
    
    // EOF
    
    // ExitMenu function
    
    void exitmenu(void)
    
    {
         clrscr();
         gotoxy(23,10);
         printf("Thank you for using this program");
         gotoxy(23,11);
         printf("Coded by: RAMTOHUL RAVIN");
    
         exit(0);
    }
    ------------------------------------------------------------------------------
    ADDING A NEW MEMBER AND CREATING A FILE
    ---------------------------------------------------------------------------------
    Code:
    /* Program Name	: Addmem.cpp
       Date 	: 08-Nov-05
       Written By	: Ramtohul Ravin
       Purpose	: Adding a member 
    */
    
    #include <stdio.h>
    #include <string.h>
    #include <conio.h>
    #include <stdlib.h>
    
    #include "screeen.h"
    
    #define  TRUE 1
    
    
    typedef struct
    
      {
        char surname[40];
        int memcode;
        char name[20];
        char street[60];
        char town[20];
        char postcode[7];
        int houseno;
        long int telno;
        float currfee;
        float outfee;
      } record;
    
     record readscreen(record member);
     void writefile(record member);
    
      FILE *fpt;
    
    main()
    
     {
       int flag = TRUE;
       record member;
    
       fpt = fopen("memberz.dat", "w");
    
    /* MAIN LOOP */
    
      while (flag)
    
        {
         drawscreen2();
    
         gotoxy(24,5);
         printf(" ***** MEMBERS PAGE ***** ");
             
         gotoxy(12,24);
         printf("*** Please Enter 'XXX' At --SURNAME-- To Finish ***");
    
          gotoxy(6,9);					/* Enter Data For Members */
          printf("SURNAME: ");
          scanf("%s", member.surname);
          							/* Test for Termination */
       if (strcmp(member.surname, "XXX") == 0)
          break;
    
          member = readscreen(member);
          writefile(member);
         }
    
      fclose(fpt);
    
     }
    
    record readscreen(record member) 		       /* Read Remaining Data */
                                                               
     {
       gotoxy(42,9);
       printf("MEMBER CODE: ");
       scanf("%d", &member.memcode);
       
       gotoxy(6,11);
       printf("NAME: ");
       scanf("%s", member.name);
    
       gotoxy(6,13);
       printf("HOUSE NO.: ");
       scanf("%d", &member.houseno);
    
       gotoxy(6,17);
       printf("TOWN: ");
       scanf("%s", member.town);
    
       gotoxy(6,19);
       printf("POSTCODE: ");
       scanf("%s", member.postcode);
    
       gotoxy(42,17);
       printf("CONTACT NO.: ");
       scanf("%d", &member.telno);
    
       gotoxy(6,21);
       printf("Total Fee For The Month: ");
       scanf(" %2f", &member.currfee);
    
       gotoxy(6,23);
       printf("Outstanding Fee for the Month: ");
       scanf(" %2f", &member.outfee);
    
       gotoxy(6,15);
       printf("STREET: ");
       scanf("%s", member.street);
    
    return(member);
    
    }
    
    void writefile(record member)  /* write remaining data to a data file */
    
       {
         fprintf(fpt, " %d\n", member.memcode);
    
         fprintf(fpt, " %s\n", member.surname);
              
         fprintf(fpt, " %s\n", member.name);
    
         fprintf(fpt, " %s\n", member.houseno);
          
         fprintf(fpt, " %s\n", member.street);
    
         fprintf(fpt, " %s\n", member.town);
    
         fprintf(fpt, " %s\n", member.postcode);
    
         fprintf(fpt, " %d\n", member.telno);
    
         fprintf(fpt, " %2f\n", member.currfee);
    
         fprintf(fpt, " %2f\n", member.outfee);
    
        return;
       }

  2. #2
    Unregistered User
    Join Date
    Sep 2005
    Location
    Antarctica
    Posts
    341
    here's a couple tips:

    1. Don't use a bunch of different colors in your post text, it's very annoying.
    2. Don't make me horizontally scroll to read your post, equally annoying.
    3. State specific problems you have, such as "This line doesn't compile", "I don't understand this piece of code", etc.

    Nobody wants to see your homework code and requirements and just figure out the assingment for you.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    4. If possible create a small example program that demonstrates your problem without having to post your entire program.

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    5. Another repetition of suggestion #2 with different wording.
    Sent from my iPadŽ

  5. #5
    Unregistered User
    Join Date
    Sep 2005
    Location
    Antarctica
    Posts
    341
    6. If your compiler is Turbo C++, post in the C++ forum.

  6. #6
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Actually, leave it here and just change the filename to mainmenu.c, not .cpp.
    Sent from my iPadŽ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 09:25 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. reading a file into a block
    By mickey0 in forum C++ Programming
    Replies: 19
    Last Post: 05-03-2008, 05:53 AM
  4. Menu Item Caption - /a for right aligned Accelerator?
    By JasonD in forum Windows Programming
    Replies: 6
    Last Post: 06-25-2003, 11:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21