This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Is it a problem in function localtime(...)?
- From: "Yang, Huaichen" <huaichen dot yang at cirrus dot com>
- To: "'cygwin at cygwin dot com'" <cygwin at cygwin dot com>
- Date: Wed, 16 Apr 2003 13:15:42 -0500
- Subject: Is it a problem in function localtime(...)?
The localtime(...) is running OK in cygwin. However, if I run the
following program out of cygwin (didn't start cygwin): When I
commented the line "loctime = localtime (&curtime)", there is no
problem. All environment variables can be shown up correctly; If
I uncommented this line, the first two environment variables were
replaced with binary characters, that crached down the program.
The problem seems that if some Cygwin environment variable
doesn't exist, the localtime() will destroy the environment
variable list, instead of returning a NULL.
#include <time.h>
#include <stdio.h>
int main (int argc, char *argv[], char *envp[])
{
time_t curtime;
struct tm *loctime;
int i;
/* Get the current time. */
curtime = time (NULL);
/* Convert it to local time representation. */
loctime = localtime (&curtime);
for (i = 0; envp[i] != 0; ++i)
{
printf("-->env[%d]=\"%s\"\n", i, envp[i]);
}
return 0;
}
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/