Thread: Need help with a project

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,735
    I've just read e) f) and g), the hint for d) works for those as well

  2. #2
    Registered User
    Join Date
    Feb 2015
    Posts
    21
    What's wrong with this function? It compiles but it doesnt print anything.

    EDIT: Or whatever, I'll just put the whole function, so you can see declaration and everything:

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #define MAX 4
    
    
    struct data {
        char name[20];
        char surename[20];
    };
    struct student {
        struct data data_s;
        float average;
        int grades[10];
    };
    int grades_f(const struct student* grades_in);
    
    
    int main(int argc, char* argv[])
    {
    
    
        struct student students[MAX];
        int grades_f(students);
        int counter = 0;
        printf("Name of the first student: ");
        gets(students[counter].data_s.name);
        while (counter < MAX) {
            printf("Student's surename: ");
            gets(students[counter++].data_s.surename);
            if (counter < MAX) {
                printf("Name of the next student: ");
                gets(students[counter].data_s.name);
            }
        }
    
    
        int grades_f(const struct student* grades_in)
        {
            int i;
            for (i = 0; i < MAX; i++, grades_in++) {
                printf("Grades of student: %d", i + 1);
                scanf("%f", grades_in->grades);
            }
        }
        system("PAUSE");
        return 0;
    }
    Last edited by Glorn; 02-04-2015 at 04:24 PM.

  3. #3
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,735
    your compiler should have complained at you for that anyway, make sure whatever setting that forces all warnings to be shown is on, normally it is called Wall

  4. #4
    Registered User
    Join Date
    Feb 2015
    Posts
    21
    That was extremely stupid of me not to notice that, however I put my function outside main() and it's still the same...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 08-02-2013, 06:45 PM
  2. Replies: 5
    Last Post: 02-23-2013, 03:37 PM
  3. Classes Project (Not class project)
    By adam.morin in forum C++ Programming
    Replies: 3
    Last Post: 02-28-2011, 01:48 AM
  4. Paid project - The Free Marketing Project
    By sharefree in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 10-27-2010, 02:15 PM
  5. your 11th & 12th grade c++ project or similar project
    By sleepyheadtony in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 01-13-2002, 05:14 PM

Tags for this Thread