# (C in bsd) time functions like ctime and localtime not working



## neel1982 (Nov 13, 2005)

Following are the code snippets. I have added time.h
i am working on freebsd platform

1.>>> time_t tim=time(NULL);
tm *now = localtime(&tim); //this is where segementation 
//fault happens
cout<<now<<"\n";

2.>>>
time_t tim=time(NULL);
char *s=ctime(&tim); //this is where 
//segmentation fault happens
s[strlen(s)-1]=0; 
printf("it is %s now.\n", s);

Please help


----------



## LoneWolf071 (Nov 10, 2004)

Moved this to the programming forum...


----------



## dhillonr (Aug 14, 2007)

Use the setenv function using the TZ. I have same problem and its working for me now
Thanks


----------

