/* * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. * * This product is part of the Amsterdam Compiler Kit. * * Permission to use, sell, duplicate or disclose this software must be * obtained in writing. Requests for such permissions may be sent to * * Dr. Andrew S. Tanenbaum * Wiskundig Seminarium * Vrije Universiteit * Postbox 7161 * 1007 MC Amsterdam * The Netherlands * */ /* Author: E.G. Keizer */ static char rcs_id[]= "$Header$" ; /* test for structure parameters, assignment and return */ # define ASIZE 26 struct w1 { int w1_i ; } ; struct w2 { int w2_i ; double w2_d ; } ; struct w3 { char w3_a[ASIZE] ; double w3_x ; } ; struct w1 es1 ; struct w1 es2[3] ; main() { asst() ; part() ; callt() ; return 0 ; } asst() { /* test structure assignment */ struct w1 st1, st2, *st3 ; struct w2 s2t1, s2t2, *s2t3 ; struct w3 s3t1, s3t2, *s3t3 ; register int i ; printf("w1\n") ; st1.w1_i = 506 ; st2 = st1 ; printf("\tst2.w1_i %d\n",st2.w1_i) ; st3 = &st1 ; printf("\t(*st3).w1_i %d\n",(*st3).w1_i) ; es1.w1_i = 711 ; st1 = st2 = es1 ; printf("\tst1.w1_i %d\n",st1.w1_i) ; printf("\tst2.w1_i %d\n",st2.w1_i) ; es2[2] = st1 ; printf("\tes2[2].w1_i %d\n",es2[2].w1_i) ; st1.w1_i = -577 ; es1.w1_i = 577 ; for ( i=0 ; i<2 ; i++ ) { st2 = ( i ? st1 : es1 ) ; printf("\tst2.w1_i %d\n",st2.w1_i) ; } st1 = ( i , es1 ) ; printf("\tst1.w1_i %d\n",st1.w1_i) ; printf("w2\n") ; s2t1.w2_i = 18000 ; s2t1.w2_d = 3.1415 ; s2t2 = s2t1 ; printf("\ts2t2: .w2_i %d .w2_d %f\n",s2t2.w2_i,s2t2.w2_d) ; s2t3 = &s2t2 ; printf("\ts2t3->w2_d %f\n",s2t3->w2_d) ; printf("w3\n") ; for ( i = 0 ; i