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 = malloc(10);
  7. strcpy(novo, a);
  8. strcpy(a, b);
  9. strcpy(b, novo);
  10. }
  11.  
  12. int main() {
  13. char *a = malloc(10);
  14. strcpy(a, "oi");
  15. char *b = malloc(10);
  16. strcpy(b, "tchau");
  17. trocar(a, b);
  18. printf("a: %s, b: %s\n", a, b);
  19. }
  20.  
  21. //https://pt.stackoverflow.com/q/344274/101
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
a: tchau, b: oi