Thread: Please Help!!! Project Due soon!!

  1. #16
    Registered User
    Join Date
    Dec 2002
    Posts
    10
    how do i pass a pointer to the first set of data kinda like...

    void sort(struct data *p);

    and what does it look like when i pass it....

    main()
    {
    sort(????)
    }

    my structure looks like this......





    struct student{
    int stdnum;
    char stdname[40];
    bool active;
    };
    struct classes{
    int stdnum;
    int classnum;
    };
    struct subject{
    int classnum;
    char classname[40];
    int topic;
    };

    //----------------------------------fill in some test data

    student data[] = {
    {1,"Hall Tim",1},
    {2,"Harren Chris",1},
    {3,"Lyons Steve",1},
    {4,"Lakis Mike",1},
    {5,"Doe John",1},
    {6,"MacMeyer Tim",1},
    {7,"Pulli Jon",1}};

    classes course[] = {
    {1,101},
    {2,101},
    {1,102},
    {3,102}};

    subject sub[] = {
    {101,"science",111},
    {102,"history",222}};



    thanks

  2. #17
    Registered User
    Join Date
    Dec 2002
    Posts
    10
    here's the code.... and here's the error....

    ld:
    Unresolved:
    sort(student*, int)


    ------------------------------------------------------------------------------
    #include<string.h>
    #include<ctype.h>
    #include<fstream.h>
    #include<stdlib.h>
    #include<string.h>

    //---------------------------------structures
    struct student{
    int stdnum;
    char stdname[40];
    bool active;
    };
    struct classes{
    int stdnum;
    int classnum;
    };
    struct subject{
    int classnum;
    char classname[40];
    int topic;
    };

    //----------------------------------fill in info

    student data[] = {
    {1,"Hall Tim",1},
    {2,"Harren Chris",1},
    {3,"Lyons Steve",1},
    {4,"Lakis Mike",1},
    {5,"Doe John",1},
    {6,"MacMeyer Tim",1},
    {7,"Pulli Jon",1}};

    classes course[] = {
    {1,101},
    {2,101},
    {1,102},
    {3,102}};

    subject sub[] = {
    {101,"science",111},
    {102,"history",222}};


    void sort(student data[], int size);



    main()
    {
    int x;

    x=sizeof(data)/48;
    sort(data,x);


    }

  3. #18
    Registered User
    Join Date
    Dec 2002
    Posts
    10
    i'm sorry for all the questions, i'm just a beginner and i really appreciate your help. My newest problem is that my strcmp() function doesn't seem to be working right....? the code never enters the if() statement...


    void sort(student array1[],struct student *p, int size)
    {
    cout << "Entered Sort Function"<< endl;
    int flag=1;
    struct student tmp;

    while(flag){
    flag =0;
    if(strcmp(p->stdname,(p+1)->stdname)>0){
    cout << "got here" << endl;
    tmp = *p;
    *(p) = *(p+1);
    *(p+1) = tmp;
    flag = 1;
    }

    }

    for(int i=0;i<size;i++){
    cout << array1[i].stdname << endl;
    }
    }


    and obviously the data doesn't change

    thanks, i really appreciate the help, you are saving me!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Project Help please!
    By black_hole??? in forum C++ Programming
    Replies: 4
    Last Post: 04-28-2009, 12:55 AM
  2. Open-source Game Project
    By Glorfindel in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 03-24-2009, 01:12 AM
  3. MFC in an empty project
    By cunnus88 in forum Windows Programming
    Replies: 0
    Last Post: 10-09-2005, 09:19 AM
  4. Game Independent Anti-cheat Project Needs Programmers
    By GIA Project Lea in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-15-2005, 07:41 PM