Problem with post-incrementation

Andre Godin 8926 godin at ireq.hydro.qc.ca
Tue Apr 16 00:48:44 AEST 1991


	Every times I call this function, the value of 'str' 
	is always tmp_0 and 'i' never gets incremented. If
	we use the pre-increment operator, the function works 
	properly. Why post-incrementing doesn't work?

	(I'm using cc under SunOs 4.0.3.)

char *
fnc() /*
----- */
{
static	int	i = 0;
static	char	str[256];

	sprintf(str, "tmp_%d", i = (i++) % 3600);

	return (str);
}




More information about the Comp.lang.c mailing list