Is this legal C?

Dave Sherman dave at utcsrgv.UUCP
Tue Nov 22 06:02:56 AEST 1983

I recently had occasion to use a construct which is a little strange,
and I was wondering whether it's guaranteed to be portable.

		if(0) retry: printf("Try again.\n");
		printf("What's two plus two? ");
		/* if get a bad answer */
		goto retry;

This code ensures that the "Try again" message isn't executed the
first time through. It works fine on the VAX (4.1bsd) and PDP-11 (v7).
Can I be sure that the "goto" to a statement within a condition
will work with any C compiler?

Dave Sherman

More information about the Comp.lang.c mailing list