Database v.2.2

This is a discussion on Database v.2.2 within the C Programming forums, part of the General Programming Boards category; More updates on my database pulling it upto v.2.2 because of: http://cboard.cprogramming.com/showt...threadid=49407 Once again....plz mark my work: 1. Program Efficiency- ...

  1. #1
    Senor Member nomi's Avatar
    Join Date
    Jan 2004
    Posts
    129

    Database v.2.2

    More updates on my database pulling it upto v.2.2 because of:
    Final Database.... :^)

    Once again....plz mark my work:
    1. Program Efficiency- /10
    2. Documentation- /10
    3. Programming Style- /10
    4. User Interface- /10

    I am attaching a *.zip file with the following contents:
    database.cpp
    database.exe
    WMinventory.dat
    WMinventory.dat.cpy

    Thanks for the help...and I will keep making changes until you guys can find mistakes. Plus, try crashing my program by enterint character instead of integars, etc...and tell me where my programme falls apart.

    Thx,
    nomi
    Attached Files Attached Files

  2. #2
    Senor Member nomi's Avatar
    Join Date
    Jan 2004
    Posts
    129
    Missed one gets() in my programme....but that's a minor problem.
    Code:
       gets(test);
    With:
    Code:
        fgets(test,MAXchar,stdin);
        test[strlen(test)-1]='\0';
    I would seriously like Prelude to go through my code, just once.

    Thx.
    Last edited by nomi; 01-19-2004 at 08:26 PM.

  3. #3
    Senor Member nomi's Avatar
    Join Date
    Jan 2004
    Posts
    129
    changed:
    Code:
        scanf("%d",&userChoice);
        while(getchar() != '\n');
    To:
    Code:
        ch = getche();
        userChoice = ch - '0';
    Making more changes....plz help me in this process.

  4. #4
    Senor Member nomi's Avatar
    Join Date
    Jan 2004
    Posts
    129
    LAtest Files.
    Attached Files Attached Files

  5. #5
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Code:
    fgets(test,MAXchar,stdin);
    test[strlen(test)-1]='\0';
    Possible problem if the user enters MAXchar characters. a modified version is this:
    Code:
    fgets(test,MAXchar,stdin);
    if ( test[strlen(test)-1]=='\n')
      test[strlen(test)-1]='\0';
    Also I like to use sizeof() for the size that way I never have to worry about changing the size of the array without changing the function. Since you are using a define it is less of a problem but I believe its a little better to use sizeof().

    Code:
    clrscr();
    This is often unneeded and destructive.

    Might look into using a switch/case instead of else if. I find it easier to read.

  6. #6
    Senor Member nomi's Avatar
    Join Date
    Jan 2004
    Posts
    129
    WaltP suggested that, but i didnt know how to implement it...

    Thanks.

  7. #7
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    switch case works like this:
    Code:
    switch ( variable that can be used as an integer )
    {
      case #1: blah; blah; blah;break;
      case #2: blah; blah; blah;break;
      ...
      default: blah; blah; blah;break;
    }
    in your case:
    Code:
        do{
            choice = mainMenu();   
            Stemplate();        
            switch ( choice )
            {
              case 1:
                do{
                    loop = addItems(inventory,&arrayL);
                  }while (loop);
                break;
              case 2:
                do{
                    loop = deleteItems(inventory,&arrayL);
                  }while (loop);
                break;
    
              case 3:  viewItems(inventory,arrayL); break;
              case 4:  sortItems(inventory,arrayL); break;
              case 5:  searchItems(inventory,arrayL);
              case 0:  exitScreen(); break;
              default:  puts("Invalid input");
            }
     
        saveData(inventory,arrayL);
        }while(choice != 0);

  8. #8
    Senor Member nomi's Avatar
    Join Date
    Jan 2004
    Posts
    129
    Lolz...i was talking about the fgets();

    THx a lot though.

    CAn you rate my programme too?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. literature database: help with planning
    By officedog in forum C++ Programming
    Replies: 1
    Last Post: 01-23-2009, 12:34 PM
  2. Creating a database
    By Shamino in forum Game Programming
    Replies: 19
    Last Post: 06-10-2007, 02:09 PM
  3. Replies: 10
    Last Post: 05-19-2006, 12:23 AM
  4. Developing database management software
    By jdm in forum C++ Programming
    Replies: 4
    Last Post: 06-15-2004, 05:06 PM
  5. Making a Simple Database System
    By Speedy5 in forum C++ Programming
    Replies: 1
    Last Post: 03-14-2003, 10:17 PM

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