Like Tree1Likes
  • 1 Post By msh

Student records program

This is a discussion on Student records program within the C Programming forums, part of the General Programming Boards category; Okay so I have a project, im almooost done, i just lack a certain function. Code: void add_record(record x, FILE ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    32

    Student records program

    Okay so I have a project, im almooost done, i just lack a certain function.

    Code:
    void add_record(record x, FILE *fp)
    {
        char ans;
        int tempid;
        do
        {
            system("cls");
    INPUT:
            printf("Student ID: "); scanf("%d", &x.idno);
            fflush(stdin);
            printf("First Name: "); gets(x.Fname);
            printf("Last Name; "); gets(x.Lname);
            strupr(x.Lname);
            printf("Course: "); gets(x.course);
            printf("Age: "); scanf("%d", &x.age);
            fflush(stdin);
            printf("Tuition: "); scanf("%f", &x.tuition);
            system("cls");
            printf("Enter another record? Y/N");
            ans=toupper(getch());
            system("cls");
            fwrite(&x,sizeof(x),1,fp);
        }while(ans=='Y');
        fclose(fp);
    }
    If the user inputs a Student Number which already exists, i want my program to ask the user again for another number and display sumthing like "Student Number already exists. Try again"

    I've tried working it out myself, but every time I input a Student Number , the program displays that it already exists, even though its not.

    What do you suggest I do?? Pleassee i need help, the project is due tomorrow

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Well, you might start with the code that shows the problem you're having...

    There is nothing in your provided sample that even approaches testing for existing codes or printing error messages about them.

  3. #3
    msh
    msh is offline
    Novice
    Join Date
    Jul 2009
    Posts
    568
    Is that a goto label I see there?
    CommonTater likes this.
    Disclaimer: This post shows my ignorance at the time of its making. I claim ownership of but not responsibility for all errors in it. Reference at your own peril.

  4. #4
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Hope that you'll be storing student Number somewhere in your program.
    After you get input student_Number, call a function that will;
    return 0 in case, if it finds the same number, else return 1.
    After this, you can further procede with your program.
    I don't care if someone doesn't like me, i was not put on earth to entertain everyone.

    No King, no Queen, I am the ACE of battle.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  2. Database assignment is Killing me!
    By Boltrig in forum C Programming
    Replies: 2
    Last Post: 11-29-2007, 03:56 AM
  3. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 01:27 PM
  4. Student Grade Program
    By Vinod Menon in forum C Programming
    Replies: 1
    Last Post: 05-31-2004, 01:32 AM
  5. LinkList Sorting in C
    By simly01 in forum C Programming
    Replies: 3
    Last Post: 11-25-2002, 01:21 PM

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