Please help me finish my assignment.

This is a discussion on Please help me finish my assignment. within the C Programming forums, part of the General Programming Boards category; Can someone please help me finish my assignment i am so frustrated i tried everything .. i am trying to ...

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    4

    Please help me finish my assignment.

    Can someone please help me finish my assignment i am so frustrated i tried everything ..

    i am trying to write a function that lists all the student records in linked lists in the hash index. The records are printed in the following order: the records in the list headed by hashtable[0] are printed first in the ascending order of the student_id, then the records in the list headed by hashtable[1] are printed in the ascending order of the student_id and so on.. the order of the printed records depends on the positions of the records in the hash index. Each record is printed in the following format :

    student_id:lastname:firstname:gpa

    if there is no record in the hash index, print:

    no record

    the function is :

    void listRecords(Student **hashtable);

    So this is what i've done so far but it still doesn't work:


    {
    int i, j;
    Student temp;

    Student *s;
    for(i=0; i<HASHTABLESIZE; i++)
    {
    for(j=i; j<HASHTABLESIZE; j++)
    {
    if(s[i].student_id > s[j].student_id)
    {
    temp = s[i];
    s[i] = s[j];
    s[j] = temp;

    }
    }printf("%d:%s:%s:%.1f\n", s->student_id, s->lastname, s->firstname, s->gpa);

    if(s[i].student_id != s[j].student_id)
    {
    printf("no record\n");
    }
    }

    }

  2. #2
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    1) Post your code using CODE TAGS!!!

    2) When you have pointers to structs like Student *my_student you access my_student's members via the little arrow instead of dot. (i.e. my_student->gpa)

    3) Do not access pointers pointing to nowhere (like *s in your program)

    4) Why are you passing Student **hashtable to the function if you are not using it anywhere?

    Work on these issues and post again.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    Code tags!!!
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Menu
    By Krush in forum C Programming
    Replies: 17
    Last Post: 09-01-2009, 02:34 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Help with a pretty big C++ assignment
    By wakestudent988 in forum C++ Programming
    Replies: 1
    Last Post: 10-30-2006, 08:46 PM
  4. Replies: 1
    Last Post: 10-27-2006, 01:21 PM
  5. Help!Help!I must finish my assignment today!!
    By NightWalker in forum C Programming
    Replies: 16
    Last Post: 06-09-2003, 10:33 AM

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