/* ctime example */
#include <stdio.h>
#include <time.h>

int main ()
{
  time_t rawtime;
  struct tm *ptr,loctime,ltime;  
  //struct tm ltime;
  size_t strtimeday,strtimemon;
  char daystring[50];
  char datestring[50];
  int d,h,s,m; 
  char basedir[]="/weather_data/";
  
  rawtime=time(NULL);
  ptr=localtime(&rawtime);
  
  s=ptr->tm_sec;
  m=ptr->tm_min;
  h=ptr->tm_hour;
  
  d=ltime.tm_year;
  printf("Number of seconds %d:%d:%d\n",h,m,s);
  strtimemon=strftime(daystring,20,"%b_%e_%G",ptr);
  strtimeday=strftime(datestring,20,"%b_%d_%G",ptr);
  printf( "Current date and time are: %s", ctime (&rawtime) );
  //printf( "Weekday is %s\n",s); 
  printf( "Number of Characters is : %d\n",strtimemon);
  printf( "value of pointer is : %d\n",ptr);
  printf( "%s\t\t%d\n",datestring,sizeof(datestring));
  
  char day[strtimemon];
  strncpy(day,datestring,strtimemon);  
  printf( "%s\t\t%d\n",day,sizeof(day));
  strcat(basedir,datestring);
 
  printf("%s\n",basedir);
  FILE *fp;
  //int size=sizeof(basedir);
  //char filename[size]=basedir;
  fp=fopen(basedir,"w");
  fprintf(fp,"You're stupid");
  fclose(fp);

return 0;
 
  
}
