Thread: Pointers and stuctures question.

  1. #1
    Registered User
    Join Date
    Nov 2014
    Posts
    45

    Pointers and stuctures question.

    I need to know how to access the nested structure using pointer, i mean i know how to do that when i have simple structure, for example:
    Code:
    struct person{
          char fname[16], lname[16];
          int age; 
                    }
    for this example i can use
    Code:
     (*pointer).age
    or
    Code:
    pointer->age
    but if i have structure like this:

    Code:
    struct date{
          int day, month, year;
    }
    
    
    struct person{ 
    char fname[16], lname[16];
    struct date birthDate;
                          }

    then how can i access the birthDate using pointer?

  2. #2
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    ptr1->ptr2->ptr2_data_member

  3. #3
    Registered User
    Join Date
    Nov 2014
    Posts
    45
    Thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help - pointer to array of stuctures
    By Jones_C in forum C Programming
    Replies: 13
    Last Post: 02-19-2009, 02:54 AM
  2. problem in freeing a "tree" of stuctures
    By stealthisnick in forum C Programming
    Replies: 26
    Last Post: 11-13-2008, 08:15 AM
  3. memory boundry alignment with stuctures
    By ed bitwise in forum C Programming
    Replies: 3
    Last Post: 05-08-2006, 11:33 AM
  4. Pointers Question.....Null Pointers!!!!
    By incognito in forum C++ Programming
    Replies: 5
    Last Post: 12-28-2001, 11:13 PM
  5. Replies: 0
    Last Post: 10-29-2001, 11:40 PM