Thread: Need Help Please

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    12

    Need Help Please

    Hi, New Here
    Im trying to do the instructions below, but when I enter my code, I can run through the B-number, but the rest of the values dont seem to do anything. I think I have created the dynamic array correctly, but I am unsure if I am using it right.

    This is how I did my dynamic array:

    typedef struct Record{
    unsigned int bNumber;
    char firstName[19];
    char lastName[19];
    char quizGrades[6];
    char projectGrades[5];
    char finalExamGrade;
    struct Record *next;
    }Record;


    Here is a copy of my code:

    Record* list;
    void Input(void){
    int i;
    Record *tailRecord;
    while(1){
    Record *newRecord = (Record*) malloc(sizeof(Record));
    printf("Please Enter Students B-Number:\n");
    scanf("%d",&newRecord->bNumber);
    printf("Please Enter Students First Name:\n");
    scanf("%18s",newRecord->firstName);
    printf("Please Enter Students Last Name:\n");
    scanf("%18s",newRecord->lastName);
    for(i = 0; i < 6; i++)
    printf("Please Enter Students Grade For Quiz # %d\n",i);
    scanf("%d", (int*)&newRecord->quizGrades[i]);
    for(i = 0; i < 5; i++)
    printf("Please Enter Students Grade For Project # %d\n",i);
    scanf("%d", (int*)&newRecord->projectGrades[i]);
    printf("Please Enter Student's Final Exam Grade");
    scanf("%d",(int*)&newRecord->finalExamGrade);

    }
    }





    Instructions:
    Create a C struct used to store data for a student in this class, as part of a dynamic array. The data for a student must include:

    B-Number (as an 'unsigned int')
    First name (up to 18 characters, not inluding the NULL)
    Last name (also up to 18 characters, not inluding the NULL)
    6 quiz grades
    5 project grades
    Final exam grade
    Each 'grade' should be a 'char' (either signed or unsigned, your choice) type, since it can only range from 0 to 100, inclusive. The definition for this struct should be written in your stlist.h header file.

    Define a static global "list" pointer for this array, and a set of functions for manipulating this list in your stlist.c file. A declaration for each of these functions - along with detailed descriptions of each, should be placed in the stlist header file. You must provide, with the functions in this file, at least the following functionality:
    Last edited by Ekrish; 12-11-2009 at 02:49 PM.

Popular pages Recent additions subscribe to a feed