fork download
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4.  
  5. #include <cstring>
  6.  
  7. int main(){
  8. std::string str("abcdef");
  9. std::cout << str << std::endl;
  10.  
  11. std::vector<char> vec(str.begin(),str.end());
  12. //必要に応じてvecのサイズ変更
  13. vec.resize(strlen("ABCDEFGHI") + 1);
  14. strcpy(&vec[0],"ABCDEFGHI");
  15. str = std::string(vec.begin(),vec.end());
  16.  
  17. std::cout << str << std::endl;
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 3032KB
stdin
Standard input is empty
stdout
abcdef
ABCDEFGHI