fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define TAMANHO 100
  4.  
  5. int main()
  6. {
  7. char x[TAMANHO];
  8. memset(&x, '\0', sizeof(char)*TAMANHO);
  9. char c = 'a';
  10. x[strlen(x)] = c; // strlen(x) retorna 0 porque está vazio
  11. c = 'b';
  12. x[strlen(x)] = c; // strlen(x) retorna 1 porque já possui 1 elemento
  13.  
  14. printf("%s", x);
  15. return 0;
  16. }
Success #stdin #stdout 0s 2008KB
stdin
Standard input is empty
stdout
ab