Skip to content

Ispit.cpp Now

if (!input.empty() && !isspace(input[0])) std::cout << (char)toupper(input[0]); Use code with caution. Copied to clipboard

A new word starts immediately following a space character. Iterate through the string, and whenever a space is detected, the next non-space character is the start of a new word. ispit.cpp

#include #include #include #include Use code with caution. Copied to clipboard and whenever a space is detected

The program reads a line of text containing multiple words and outputs a single string where each character represents the starting letter of a word in the original input. Input: mirko soft → Output: MS int main() string s

#include #include #include using namespace std; int main() string s; getline(cin, s); // Output first character if(s.length() > 0) cout << (char)toupper(s[0]); // Look for spaces to find the start of the next words for(int i = 0; i < s.length(); i++) if(s[i] == '-' cout << endl; return 0; Use code with caution. Copied to clipboard