fork(1) download
  1. #include <stdio.h>
  2.  
  3. typedef struct
  4. {
  5. int x;
  6. int y;
  7. } Point;
  8.  
  9. Point
  10. foo(int x, int y)
  11. {
  12. Point p;
  13. if (x > 0 && y > 0) {
  14. p.x = x;
  15. p.y = y;
  16. } else {
  17. p.x = 0;
  18. p.y = 0;
  19. }
  20. return p;
  21. }
  22.  
  23. int
  24. main(void)
  25. {
  26. Point p;
  27.  
  28. p = foo(1, 2);
  29. printf("(%d, %d)\n", p.x, p.y);
  30.  
  31. p = foo(3, -4);
  32. printf("(%d, %d)\n", p.x, p.y);
  33.  
  34. return 0;
  35. }
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
(1, 2)
(0, 0)