My program is complete and working, but I would like second opinions on it. The program prompts the user to enter something like a phrase or some words. Then it will create an acronym of what was entered. What are some adjustments I can make to my program to make it more efficient?
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
string acronym(string str);
int main()
{
string str;
while (true)
{
cout << "\nPlease enter a string: ";
getline(cin, str);
if (str == "")
{
break;
}
cout << "\n\nThe acronym is \"" << acronym(str) << "\"" << "\n";
}
system("PAUSE");
return 0;
}
string acronym(string str)
{
string phrase = "";
phrase = str[0];
for (int i = 0; i < str.length(); i++)
{
if (str[i] == ' ')
{
phrase += str[i+1];
}
}
return phrase;
}