accessing structure pointer problem

This is a discussion on accessing structure pointer problem within the C Programming forums, part of the General Programming Boards category; Hi, just wondering how I can assign the member of the "struct tm" to an integer? I tried doing the ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    31

    accessing structure pointer problem

    Hi, just wondering how I can assign the member of the "struct tm" to an integer? I tried doing the following, but get the error message "dereferencing pointer to incomplete type". when I do line 5 to line 8. Thanks in advance.

    Code:
      int hour,sec,min;
      time_t now;
      struct tm *tm_now;
      now=time(NULL):
      tm_now=localtime(&now);
      hour=tm_now->tm_hour; /* starting here  */
      min=tm_now->tm_min;
      sec=tm_now->tm_sec;
    'The bigger they are, the harder they fall' ~Yang

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Have you got
    Code:
    #include <time.h>
    at the top of your code?

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Are you including <time.h>?

    > now=time(NULL):
    And what's with the : at the end of this line?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 03-20-2008, 07:59 AM
  2. Structure - Typedef accessing problem
    By dayknight in forum C Programming
    Replies: 4
    Last Post: 08-11-2006, 11:52 PM
  3. Another pointer problem
    By mikahell in forum C++ Programming
    Replies: 21
    Last Post: 07-20-2006, 07:37 PM
  4. Can a pointer point to different data structure?
    By franziss in forum C Programming
    Replies: 9
    Last Post: 09-04-2005, 11:51 AM
  5. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21