title: How do I access a globally defined typedef struct through pointers?
body: <p>I want to know how to use a typedef struct outside the file where it is located. I mean, I have this:</p>
  
  <p>In a File called "rtc_i2c.c" I have ------------------------------------</p>
  
  <pre><code>#include "rtc_i2c.h"
  
  struct time_date_str
  {
    char year;
    char month;
    char date;
    char day;
  
    char hour;
    char minute;
    char second;
  };
  
  
  int RTCGetTime(TimeDate *timdatstrptr)
  {
    timdatstrptr -&gt; second = 0x12;
  
    return 0;
  }
  </code></pre>
  
  <p>Then in a file called "rtc_i2c.h" I have -------------------------------</p>
  
  <pre><code>#ifndef RTC_I2C_H 
  #define RTC_I2C_H 
  
  typedef struct time_date_str TimeDate;
  
  #endif
  </code></pre>
  
  <p>And in "main.c" I have -------------------------------------------------</p>
  
  <pre><code>#include "rtc_i2c.h"
  
  TimeBase *TimeDateData;
  
  void main(void)
  {
    char DateTimeASCII[20]; 
  
    RTCGetTime(TimeDateData);
  
    DateTimeASCII[0] = ????????
  }
  </code></pre>
  
  <p>Then when I step in to my code I enter in to RTCGetTime and in a watch window I can see the "timdatstrptr -> second = 12" assignment executing correctly. But the problem is outside. The compiler generates an error if I put "TimeDateData --> second" in the space with ????????. So I don't know how am I supposed to access the contents of my globally defined array through a pointer.</p>
  
  <p>If I understood, the pointer declared as "TimeBase *TimeDateData" is pointing to my array and is accessed with the "-->" because is a pointer. Am I wrong? how does this work?</p>
  
  <p>Can anyone help me please? Thanks!!</p>