fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <cstring>
  5.  
  6. int main()
  7. {
  8. char features[20];
  9. std::vector<std::string> words = { "123","456","789" };
  10.  
  11. int i = 0;
  12. for (size_t n = 0; n < words.size(); ++n)
  13. {
  14. for (size_t m = 0; m < words[n].size(); ++m)
  15. features[i++] = words[n][m];
  16. features[i++] = 0;
  17. }
  18. features[i] = 0; //<-- extra terminating null
  19.  
  20. char *features_ptr = features;
  21. while (*features_ptr)
  22. {
  23. std::cout << features_ptr << std::endl;
  24. features_ptr += std::strlen(features_ptr) + 1;
  25. }
  26. }
Success #stdin #stdout 0s 4448KB
stdin
Standard input is empty
stdout
123
456
789