fork download
  1. #include <stdio.h>
  2.  
  3. typedef struct{
  4. int x, y, z;
  5. } struct_a;
  6.  
  7. void add(struct_a *r){
  8. r->x++;
  9. }
  10.  
  11. int main(void) {
  12.  
  13. struct_a s1 = {1,2,3},s2,*s3;
  14. s2=s1;
  15. s3=&s1;
  16. add(&s1);
  17.  
  18. printf( "s1=%d %d %d\n", s1.x, s1.y, s1.z );
  19. printf( "s2=%d %d %d\n", s2.x, s2.y, s2.z );
  20. printf( "s3=%d %d %d\n", s3->x, s3->y, s3->z );
  21. return 0;
  22. }
  23.  
  24.  
Success #stdin #stdout 0.01s 5424KB
stdin
Standard input is empty
stdout
s1=2 2 3
s2=1 2 3
s3=2 2 3