fork download
  1. # include <stdlib.h>
  2. # include <stdio.h>
  3.  
  4. char * read()
  5. {
  6. int sz = 8, i = 0;
  7. char * buf = malloc(sizeof(char)*sz);
  8. for(int c = fgetc(stdin); c != EOF && c != '\n'; c = fgetc(stdin))
  9. {
  10. buf[i++] = c;
  11. if (i == sz)
  12. {
  13. sz *= 2;
  14. buf = realloc(buf,sz);
  15. }
  16. }
  17. buf[i] = 0;
  18. return buf;
  19. }
  20.  
  21. int main()
  22. {
  23.  
  24. char * buf = read();
  25. int len = strlen(buf);
  26.  
  27. printf("%d\n",len);
  28.  
  29. }
  30.  
  31.  
Success #stdin #stdout 0s 5504KB
stdin
0123456789abcdefghijkl
stdout
22