jjr@ut-ngp.UUCP (02/21/87)
Consider typedef struct { float foo[100], bar[100]; } mytype; mytype x, y; I have found that y = x; does the same thing as for(i = 0; i < 100; i++) { y.foo[i] = x.foo[i]; y.bar[i] = x.bar[i]; } Is this shortcut portable? Does the ANSI standard allow it? Jeff Rodriguez jjr@ngp.utexas.edu
alyce@itsgw.UUCP (02/24/87)
In article <4741@ut-ngp.UUCP>, jjr@ut-ngp.UUCP (Jeff Rodriguez) writes: [ For struct {float foo[100], bar[100];} x, y; ] > I have found that > y = x; > does the same thing as > for(i = 0; i < 100; i++) > { y.foo[i] = x.foo[i]; y.bar[i] = x.bar[i]; } > Is this shortcut portable? Does the ANSI standard allow it? Structure assignment is relatively new (Sys V or maybe even SVR2 on AT&T UNIX -- don't know about Berkeley), so don't count on it being at all portable! Alyce Faulstich ...!seismo!rpicsv!rpitsgw!alyce alyce@itsgw.rpi.edu
news@cit-vax.UUCP (02/27/87)
Organization : California Institute of Technology Keywords: From: jon@oddhack.Caltech.Edu (Jon Leech) Path: oddhack!jon In article <371@itsgw.UUCP> alyce@itsgw.UUCP (Alyce Faulstich) writes: >Structure assignment is relatively new (Sys V or maybe even SVR2 >on AT&T UNIX -- don't know about Berkeley), so don't count on it >being at all portable! Try again. Structure assignment was first introduced (along with enums) in ``Recent Changes to C'', dated November 15, 1978 in my 7th edition, volume 2A manual. Some of the micro compilers probably didn't have it at first, along with other ``unimportant'' features (like floating point). If yours doesn't have it now, get a better compiler. -- Jon Leech (jon@csvax.caltech.edu || ...seismo!cit-vax!jon) Caltech Computer Science Graphics Group __@/