C++ string only letters -
C++ string only letters -
i've got this. problem strings must letters only, how can this? i've been sitting on few hours , can't find working solution. i've tried utilize answers topic accept letters guess i'm dumb , still can't create work :(
class="lang-cs prettyprint-override">#include <string> #include <vector> #include <iostream> #include <iterator> #include <algorithm>   using namespace std;  int main(void) { vector <string> strings; string line;   { cout << "enter string, 'stop' stops: "; cin >> line; strings.push_back(line); }  while (line != "stop");  vector <string> :: iterator w; cout << "before sorting \n"; (w=strings.begin(); w!=strings.end(); w++) cout << *w << endl;  sort (strings.begin(),strings.end()); cout << "after sorting \n"; (w=strings.begin(); w!=strings.end(); w++)  cout << *w << endl;  }       
you need add together validation code. simple cases, can like:
if ( std::find_if( line.begin(),                    line.end(),                    []( unsigned char ch ) {  homecoming !isalpha( ch ); }         ) != line.end() ) {     //  not letters }    (this appropriate school projects, , won't work usual network encoding, utf-8.)
 c++ 
 
Comments
Post a Comment