Alain Bonnefoy <alain.bonnefoy@rieter.com> wrote:
it seems that strftime() set errno to 3 !? Just try:
I remember trying to track down whether or not a function was
allowed/not allowed to modify errno in the case of a successful
return a while back.
I seem to recall that ANSI C, C99, and POSIX all had slightly
differing things to say about it.
It is, generally, good coding practice to assume:
if error return
if function is doc’ed as setting errno
errno is valid
else
errno value is undefined
else
errno value is undefined
Though, for some classifications of functions (might have been
POSIX), errno was not allowed to be changed unless the function
failed.
-David
#include <stdio.h
#include <stdlib.h
#include <time.h
#include <errno.h
int main( void )
{
time_t time_of_day;
char buffer[ 80 ];
time_of_day = time( NULL );
printf(“errno = %d\n”,errno);
strftime( buffer, 80, “Today is %A %B %d, %Y”,
localtime( &time_of_day ) );
printf(“errno = %d\n”,errno);
printf( “%s\n”, buffer);
return EXIT_SUCCESS;
}
–
Please follow-up to newsgroup, rather than personal email.
David Gibbs
QNX Training Services
dagibbs@qnx.com