Z
Zach
[semantics of argument to the exit function]
Or do both standards only define the constants EXIT_SUCCESS and
EXIT_FAILURE and most compiler implementations associate 0 with
EXIT_SUCCESS and 1 with EXIT_FAILURE? Which standard should I follow
in general practice?
Both C89 and C99 have the same wording in this area:
If the value of status is zero or EXIT_SUCCESS, an
implementation-defined form of the status successful
termination is returned. If the value of status is
EXIT_FAILURE, an implementation-defined form of the status
unsuccessful termination is returned. Otherwise the status
returned is implementation-defined.
My guess is that 0 for EXIT_SUCCESS and 1 for EXIT_FAILURE is
most common. POSIX requires that EXIT_SUCCESS be 0 (but only
requires that EXIT_FAILURE be nonzero, not that it be 1).
Also, I've seen in code other values such as:
exit(3);What do these other values (besides 0 and 1) indicate specifically and
which should I use to have good, portable C code?
The meaning of other status values is implementation defined. I
would use one of the standard exit codes in portable C code.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa67f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1utchar(a[i&15]);break;}}}
Hi Ben,
Cool .sig BTW Thanks. I heard you wrote a C book, is it still
available?
Zach