fork(1) download
  1. /** Call by address */
  2. #include <stdio.h>
  3. void swap(char **s, char **p) {
  4. char *t = *p;
  5. *p = *s;
  6. *s = t;
  7. }
  8. int main() {
  9. char *one = "First", *two = "Second";
  10. swap(&one, &two);
  11. printf("%s %s\n", one, two);
  12. }
  13.  
  14. /** Call by reference */
  15. /*#include <stdio.h>
  16. void swap(char *&s, char *&p) {
  17. char *t = s;
  18. s = p;
  19. p = t;
  20. }
  21. int main() {
  22. char *one = "First", *two = "Second";
  23. swap(one, two);
  24. printf("%s %s\n", one, two);
  25. }*/
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Second First