#define's Profile User Rating: *****

Reputation: 1464 Grandmaster
Active Posts:
5,091 (2.31 per day)
19-February 09
Profile Views:
Last Active:
User is offline Feb 26 2015 02:45 PM

Previous Fields

Who Cares
OS Preference:
Favorite Browser:
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Your Car:
Dream Kudos:
Expert In:

Latest Visitors

Icon   #define has not set their status

Posts I've Made

  1. In Topic: Not understanding structure pointers and arrays in C

    Posted 26 Feb 2015

    Hi, because id and name are part of the student structure, there is little need to prefix them with stu or student.

    #define NAMEMAXSIZE 80
    #define STUDENTLISTMAX 100
    typedef struct
      int   id;
      char  name[NAMESIZEMAX];
    } student_record;
    typedef struct
      int count;
      student_record list[STUDENTLISTMAX];
    } students_list;

    Many students take one course, and one student takes many courses. So do you have a student object that takes a list of course id's, or a course object with a list of student id's, or both?. That's getting to sound complicated.

    There is another way, usual in databases. You use a structure/record to model a one to one relationship. So one record holds one student's enrollment in one course, and has a grade for the course.

    typedef struct
      int  student_id;
      int  course_id;
      int  grade;
    } enrollment_record;
    typedef struct
      int count;
      enrollment_record list[100];
    } enrollment_list;
  2. In Topic: Printing without Printf Statements?

    Posted 26 Feb 2015

    Hi, I don't think this very easy for a beginner, nor do I think it is terribly difficult, perhaps you could say it is slightly tricky.

    Maybe try a different tack, and just try and produce the pattern and forget about the end lines for now.
  3. In Topic: Function not returning Values; structs in arrays

    Posted 25 Feb 2015

    Hi, it looks like votes_rec/t will likely be a fraction less than 1, so the result of the integer division will be 0.

    Try using a float constant and multiplying first.

    candidate[c].vote_percent = (100.0 * candidate[c].votes_rec) / t;
  4. In Topic: Printing without Printf Statements?

    Posted 25 Feb 2015

    View Post285matt, on 25 February 2015 - 03:12 PM, said:

    I got rid of the else if but it looks so ugly and terrible.

    As well as whitespace, you can use row or r and col or c for the iterators.

      for(row=0; row<height; row++)
        for(col=0; col<width; col++)
          // ...

    Instead of specifying the rows,

      if (i == 0|| i == 1|| i == (height-1)|| i == (height-2))
        // ...

    you can use less than and greater than ...

      if (row <= 1 || row >= (height-2))
        // ...
  5. In Topic: Least used character in Pascal

    Posted 24 Feb 2015

    You could use an array to hold a count of each character, eg an array of char of size 26 to represent 'a' to 'z'.

My Information

Member Title:
Duke of Err
Age Unknown
Birthday Unknown
Delta Quadrant
Years Programming:
Programming Languages:

Contact Information

Website URL:
Website URL  http://


Page 1 of 1
  1. Photo

    GryphonClaws Icon

    10 Jan 2013 - 01:15
    Thanks #define. I can't believe I missed such a simple detail.
  2. Photo

    raghav.naganathan Icon

    07 Nov 2012 - 20:40
    Dude...before your reputation changes, I would like to tell you that it(729) is a perfect cube :) Cheers :)
Page 1 of 1