fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void trocar(char **a, char **b) {
  6. char *novo = *a;
  7. *a = *b;
  8. *b = novo;
  9. }
  10.  
  11. int main() {
  12. char *a = malloc(3);
  13. strcpy(a, "oi");
  14. char *b = malloc(6);
  15. strcpy(b, "tchau");
  16. trocar(&a, &b);
  17. printf("a: %s, b: %s\n", a, b);
  18. }
  19.  
  20. //https://pt.stackoverflow.com/q/344274/101
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
a: tchau, b: oi