When is a statement an expression?

Geoff Rimmer geoff at cs.warwick.ac.uk
Sat Apr 29 18:04:55 AEST 1989


In article <2208 at pur-phy> sho at pur-phy (Sho Kuwamoto) writes:
> In article <1043 at itivax.iti.org> scs at vax3.iti.org (Steve Simmons) writes:
> <	a = if ( a == 1 )
> <		12 ;
> <	else
> <		14 ;
> 
> 2) "12;" cannot be executed.  It is not a legal expression.

'12'  is an expression.
'12;' is a statement.

Anything that is a valid expression (such as '12') can always be made
into a valid statement by adding a ';'.  OK, so it might not *do*
anything to have a statement "12;" but it is syntactically correct C.

> -Sho

Geoff

	/---------------------------------------------------------------\
	|	GEOFF RIMMER  - Friend of fax booths, ANSI C, PCBH,	|
	|			phone *numbers*	& MPFC & printf		|
	|	email	: geoff at uk.ac.warwick.emerald			|
	|	address : Computer Science Dept, Warwick University, 	|
	|		  Coventry, England.				|
	|	PHONE	: +44 203 692320 (10 lines) If I'm out please	|
	|			   leave a message with my secretary.	|
	|	FAX	: +44 865 726753				|
	\---------------------------------------------------------------/



More information about the Comp.lang.c mailing list