fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4.  
  5. int main()
  6. {
  7. std::string s;
  8. s.resize(6);
  9.  
  10. char c[] = "hello";
  11.  
  12. strncpy(&s[0], c, 6);
  13.  
  14. std::cout << s << std::endl;
  15. }
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
hello