I have thought of using if statements but that would be long. any other ideas or maybe some string methods that I don't know about.
the question is(kind of):
in given string input, search for non-letter and non-number character like(',','@') and prompt user to choose between them as the separator to store different parts of string. eg;
For example, if you see input like this:
Alex Allain, webmaster@cprogramming.com
John Smith, john@nowhere.com
You should prompt the user to choose between comma, at sign, and period for the separator.
my present logic is like:
1 2 3 4 5 6 7 8 9 10 11
|
string string_input;
cout<<"enter a line: ";
getline(cin,string_input,'\n');
cout<<"the non-letter and non-number characters used are: ";
for(int i=0;i<string_input.length();i++)
{
if(string_input[i]!='a'&&string_input[i]!='b')....(upto z)&&string_input[i]!='0'...(continued)...string_input[i]!='9')
{
cout<<string_input[i];
}
}
|