fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #define SIZE 4
  5.  
  6. struct Person
  7. {
  8. char name[16], dep[16];
  9. float cyi, ra, rp, npa, tyi, tra, tpa;
  10. };
  11.  
  12.  
  13. int main()
  14. {
  15. struct Person s[SIZE];
  16. strcpy(s[0].name, "Name 1");
  17. strcpy(s[0].dep, "Department 1");
  18.  
  19. strcpy(s[1].name, "Name 2");
  20. strcpy(s[1].dep, "Department 2");
  21.  
  22. // Swap.
  23. s[2] = s[0];
  24. s[0] = s[1];
  25. s[1] = s[2];
  26.  
  27. printf("%s %s\n", s[0].name, s[0].dep);
  28. printf("%s %s\n", s[1].name, s[1].dep);
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
Name 2 Department 2
Name 1 Department 1