fork download
  1. #include <stdio.h>
  2.  
  3. size_t strcpylen(char *dest, const char *src) {
  4. const char *s = src;
  5. while ((*dest++ = *s++))
  6. ;
  7. return s - src - 1;
  8. }
  9.  
  10. int main(void) {
  11. char buf[20];
  12. size_t len = strcpylen(buf, "hello");
  13. printf("%d '%s'\n", (int)len, buf);
  14. return 0;
  15. }
  16.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
5 'hello'