Thread: Help! why this not work

  1. #1
    CDumbie
    Guest

    Help! why this not work

    Hi,
    Below program gave me many errors and I can't figure out why.
    Code:
    typedef struct 
    {
       int ID;
       float exam1;
       float exam2;
    } studentRecord;
    
    
    studentRecord stuRecordArr[40];
    
    int main()
    {
       int i;
       for (i =0; i<40; i++)
       {
          stuRecordArr[i].studentRecord.ID = 0; /* gave errors, why?*/
       }  
    
      return 0;
    }
    How to access to a record field for above program?
    Thank you for your help.
    CDumbie

  2. #2
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    your sintax is wrong.

    stuRecordArr[i].ID = 0;
    hello, internet!

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    stuRecordArr[i].studentRecord.ID = 0;

    Should be

    stuRecordArr[i].ID = 0;

    studentRecord is the datatype, but stuRecordArr[?] is the actual object of that type.
    Ie you never type:

    int Myvar;
    MyVar.int = 5;

    when assigning a value to an int .
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 07:48 PM
  2. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 10:50 AM
  3. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 10:39 PM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. DLL __cdecl doesnt seem to work?
    By Xei in forum C++ Programming
    Replies: 6
    Last Post: 08-21-2002, 04:36 PM