Implement a program that, given a person’s name, prints a person’s initials, per the below.
$ ./initials Regulus Arcturus Black RAB
Design and implement a program,
initials, that, given a person’s name, prints a person’s initials.
Implement your program in a file called
initials.cin a directory called
Your program should prompt a user for their name using
get_stringto obtain their name as a
You may assume that the user’s input will contain only letters (uppercase and/or lowercase) plus single spaces between words. You don’t need to worry about names like
Conan O’Brien, or
David J. Malan!
Your program should print the user’s initials (i.e., the first letter of each word in their name) with no spaces or periods, followed by a newline (
Your program should behave per the examples below. Assumed that the underlined text is what some user has typed.
$ ./initials Zamyla Chan ZC
$ ./initials robert thomas bowden RTB
- Might the user’s input start or end with spaces?
No, you may assume that the only spaces in the user’s input will be single spaces between words. A previous version of this problem’s walkthrough incorrectly stated that there might be spaces at the start or end of the user’s input, but the video has since been fixed! Apologies for any confusion!
Corrected walkthrough, added FAQ about spaces at input’s start and end.