fork download
  1. #include <iostream>
  2.  
  3. int main() {
  4. unsigned char pc[4] = {'t','e','s','t'};
  5.  
  6. std::cout << std::string(&pc[0], &pc[3]) << std::endl;
  7. std::cout << std::string(&pc[0], &pc[4]) << std::endl;
  8.  
  9. std::string s("abc");
  10.  
  11. std::cout << std::string(s.begin(), s.end()) << std::endl;
  12.  
  13. return 0;
  14. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
tes
test
abc