fork download
  1. #include <stdio.h>
  2.  
  3. struct Test {
  4. char str;
  5. };
  6.  
  7. void change1(struct Test *t){
  8. t->str = 'B';
  9. }
  10.  
  11. void change2(struct Test *t){
  12. static struct Test tmp = { 'A' };
  13. *t = tmp;
  14. t->str = 'B';
  15. }
  16.  
  17. int main(void) {
  18. struct Test t1 = { 'A' };
  19. change1(&t1);
  20. printf("%c\n", t1);
  21.  
  22. struct Test t2 = { 'A' };
  23. change1(&t2);
  24. printf("%c\n", t2);
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
B
B