initialization

Chris Schoeneman jindak at surfside.sgi.com
Thu Aug 2 03:19:25 AEST 1990


In article <1990Aug1.011654.22068 at ccu.umanitoba.ca> rpjday at ccu.umanitoba.ca
writes:
>int func(int a) 
>{
>	int i = a, j = i + 1 ;
>
>Am I allowed to initialize the integer "j" with the value of 
>another variable initialized in the same line?

Of course you're allowed.  C doesn't care if "i" is initialized or not!

But don't worry, the comma operator is evaluated left to right.  So your
code will always work correctly (i.e. "a" will be assigned to "i", then
"i"+1 will be assigned to "j").

	       Chris Schoeneman | I was neat, clean, shaved and sober,
    jindak at surfside.esd.sgi.com | and I didn't care who knew it.
	 Silicon Graphics, Inc. |		-Raymond Chandler
	      Mountain View, CA |		 (The Big Sleep)



More information about the Comp.lang.c mailing list