order.c

/*
 * simple program to show the order of evaluation of function parameters
 * we do 4 in case the compiler is weird and does something like 1423;
 * almost always it does 1234 or 4321 (left to right or right to left)
 *
 * Matt Bishop, ECS 36A
 * April 22, 2024
 *	first version
 */
#include <stdio.h>

/*
 * these are passd as arguments to printf in the order of the numbers
 * and return a string saying where in the parameter list they were 
 */
char *f1(void) { return("first argument"); }
char *f2(void) { return("second argument"); }
char *f3(void) { return("third argument"); }
char *f4(void) { return("fourth argument"); }

/*
 * one routine to rule them all . . .
 */
int main(void)
{
	/* print out the returned strings from the functions */
	printf("order of evaluation:\n%s / %s / %s / %s\n",
						f1(), f2(), f3(), f4());

	/* bye bye! */
	return(0);
}


UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: [email protected]
ECS 36A, Programming & Problem Solving
Version of April 2, 2024 at 12:13PM

You can get the raw source code here.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh