#include "iostream" #include #include #include int main() { std::string msg = "hello world"; for (int i = 0; i < msg.length(); i++) { std::cout << msg[i]; if (i != msg.length() - 1 && msg[i+1] != ' ' && msg[i] != ' ') std::cout << '-'; } return 0; }