this supposed to return any string in alpha order
my thought is to read the entire string and compare two chars a time, then sort in order
I realize I'm not returning anything yet, but I'm stuck on the working func...any thoughts?
#include <iostream>
#include <string>
using namespace std;
void alpha (string &s);
int main()
{
string text;
cout<<"Please enter a string: ";
cin >> text;
alpha (text);
cout <<"Alphabetized: " ;
return 0;
}
void alpha (string &s)
{
string text;
int str_length = text.size();
getline(cin, text);
for (int i = 0; i<str_length; i++)
{
for (int j=i+1;j<str_length ;j++ )
{
if (s[i] != ' ' || s[j] != ' ')
{
for (int k = j; k < str_length; k++)
{
if (s[k] < s[j])
cout << s[j];
else
cout << s[k];
}
}
}
}
}