fork download
  1. #include <iostream>
  2. #include <cstring>
  3. #define n 100
  4. using namespace std;
  5. int cnt = 0;
  6.  
  7.  
  8. int main() {
  9. char src[] = "Hello World";
  10. char dst[20];
  11. strncpy(dst, src, sizeof(dst));
  12. printf(":%zu:", strlen(dst));
  13. memcpy(dst, src, 5);
  14. printf(":%zu:", strlen(dst));
  15. strncpy(dst, src,5);
  16. printf(":%zu:", strlen(dst));
  17. return 0;
  18. }
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
:11::11::11: