Is simple assignment allowed with structs

Asim Jalis aj3u at wilbury.ra.cs.virginia.edu
Sun Mar 31 07:12:51 AEST 1991


My compiler accepts the following program:

struct s 
{ int x; 
  int y 
} a,b;
main() 
{ a.x = 10 ; a.y = 29;
  print(a);print(b);
  b = a; 
  print(a);print(b);
  a.x = 200 ; a.y = 34;
  print(a);print(b);
}

The assignment from all appearances seems to copy both the fields of a
to b.  My question is, is such assignment legal.  Can I expect other
compilers to support this?  Or should I explicitly assign the fields
to ensure portability.  

I tried adding two structs and that did not work.

Comments?  Suggestions?



More information about the Comp.lang.c mailing list