Solved

I am lost with the C time tm struct

Posted on 2014-09-30
3
214 Views
Last Modified: 2014-09-30
I am transfering old libs from bcc32 to tcc. I am blocked by this one in the marked line. Tcc says "structure or union expected".

Question: what is wrong with tcc.

The rest of the function is not debugged yet, tcc seems to proceed one problem at a time.
Thank you for your help.

long m_time(long tim0)
{
long   tx;
int    k;
int    mod;
int    mois, an;
struct tm * t;
time_t timer;
char   fig[10];
int    i;

   time(&timer);
   t=localtime(&timer);
   sprintf(mc_eurodate,"%02d/%02d/%02d %02d:%02d:%02d",
           t.tm_mday,t.tm_mon,t.tm_year+1900,t.tm_hour,t.tm_min,t.tm_sec);    <=== error line.
   sprintf(mc_univdate,"%04d/%02d/%02d %02d:%02d:%02d",
           t.tm_year+1900,t.tm_mon,t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec);
   sprintf(mc_gdh     ,"%04d%02d%02d%02d%02d%02d",
           t.tm_year+1900,t.tm_mon,t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec);
   sprintf(mc_soa     ,"%04d%02d%02d%02d",
           t.tm_year+1900,t.tm_mon,t.tm_mday,t.tm_hour);
   sprintf(mc_hour    ,"%02d", t.tm_hour );
   sprintf(mc_zipdate ,"%02d%02d%04d", t.tm_mon,t.tm_mday,t.tm_year+1900);
   sprintf(curr_date,"%-8.8s",mc_gdh);
   sprintf(mc_collmois,"%04d%02d",t.tm_year+1900,t.tm_mon);
   mois=d.da_mon;
   an  =t.tm_year+1900&100;
   memmove(mc_collmois,&mc_collmois[2],5);
   sprintf(mc_collweek,"%04ld",(timer+86400L*(t.tm_day+2L)+
           3600L*t.tm_hour)/604800L-524L);
   sprintf(mc_collday,"%0ld",(timer/86400L)-3653L);
   if (strlen(mc_collday)==5) memmove(mc_collday,&mc_collday[1],5);
  
   for (i=0;i<6;i++)
   {
      sprintf(mc_mois[0],"%02d%02d",an, mois--);
      if (mois==0) {mois=12; an--;}
   }

   tx=timer-315360000L;
   memset(fig,0,10);
   memset(fig,' ',9);
   k=7;
   while(1)
   {
      mod=tx%34;
      if      (mod<8)   fig[k]=mod+'A';
      else if (mod<13)  fig[k]=mod+'A'+1;
      else if (mod<24)  fig[k]=mod+'A'+2;
      else              fig[k]=mod+'0'-24;
      k--;
      if ((tx=tx/34)==0L) break;
   }
   m_head(fig);
   m_short(fig);
   sprintf(mc_ref,"%s",fig);

   mois=t.tm_mon;
   an  =t.tm_year+1900;
   mois=mois-7;
   if (mois<1) {mois=12+mois; an--;}
   sprintf(mc_six,"%04d%02d",an,mois); 
   mois=t.tm_mon;
   an  =t.tm_year+1900;
   mois=mois-12;
   if (mois<1) {mois=12+mois;an--;}
   sprintf(mc_eleven,"%04d%02d",an,mois); 
   return(timer+tim0);
}

Open in new window

0
Comment
Question by:versailles
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 500 total points
ID: 40352200
Hi versailles,

the problem IMO is you use '.' instead of '->' to access members of 't' (which is a pointer).

So you should replace all statements like ' t.tm_mda' with ' t->tm_mda'.

Hope that helps,

ZOPPO
0
 

Author Closing Comment

by:versailles
ID: 40352307
This does help !
Silly of mine. I am somewhat rusty with my C. I change compiler because BCC32 is out of commission now.
Thank you!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
cURL: stopping a http transaction before it's finished 3 136
Line meaning 9 97
C Programming - If Statement 8 84
windows 10 pro lost profile. 10 85
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question