fork download
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <cstring>
  4.  
  5.  
  6. char* my_strcpy( char* arr_out, char* arr_in, int bloc )
  7. {
  8. char* pc= arr_out;
  9.  
  10. for(size_t i=0;i<bloc;++i)
  11. {
  12.  
  13. *arr_out++ = *arr_in++ ;
  14. }
  15.  
  16. *arr_out = '\0';
  17. return pc;
  18. }
  19.  
  20. int main()
  21. {
  22. char * out= new char[20];
  23. my_strcpy(out,"12345aa\\0aaaaa AA",20);
  24. std::cout<<"output data: "<< out << std::endl;
  25. std::cout<< "the length of my output data: " << strlen(out)<<std::endl;
  26. system("pause");
  27. return 0;
  28. }
Success #stdin #stdout #stderr 0s 3428KB
stdin
Standard input is empty
stdout
output data: 12345aa\0aaaaa  AA
the length of my output data: 18
stderr
sh: pause: not found