Dzielenie ciągu na wyrazy

0

Witam ^^
Mam taki drobny problem, a mianowicie mam taki oto kod:

 
string s,ss;
  int i,n;
  unsigned char c;

  getline(cin,s);
  ss = "";
  s += " "; // dodajemy wartownika
  n = s.length();
  for(i = 0; i < n; i++)
  {
    c = s[i];
    if(((c >= '0') && (c <= '9')) || (c == '_') || (c == '-')  ||
       ((c >= 'A') && (c <= 'Z')) ||((c >= 'a') && (c <= 'z')) ||
        (c == 164) || (c == 165)  || (c == 143) || (c == 134)  ||
        (c == 168) || (c == 169)  || (c == 157) || (c == 136)  ||
        (c == 227) || (c == 228)  || (c == 224) || (c == 162)  ||
        (c == 151) || (c == 152)  || (c == 141) || (c == 171)  ||
        (c == 189) || (c == 190))
      ss += c;
    else if(ss != "")
    {
      cout << "[" << ss << "]\n";
      ss = "";
    }
  }
  

Dzieli on podany ciąg na słowa. A teraz moje pytanie, jak zrobić by znaki typu: "!" "," "." ";" "?" - traktował jako pojedyńcze słowo?

Vision,
Z góry THX.

0
     c = s[i];
    if( c=='!' ||  c==',' || c=='.' || c==';' || c=='?')
    {
       if (strcmp(ss,"") != 0)
      {
         cout << "[" << ss << "]\n";
         ss = "";          
      }

      cout << "[" << c << "]\n";
    }
    else  if(((c >= '0') && (c <= '9')) || (c == '_') || (c == '-')  ||
       ((c >= 'A') && (c <= 'Z')) ||((c >= 'a') && (c <= 'z')) ||
        (c == 164) || (c == 165)  || (c == 143) || (c == 134)  ||
        (c == 168) || (c == 169)  || (c == 157) || (c == 136)  ||
        (c == 227) || (c == 228)  || (c == 224) || (c == 162)  ||
        (c == 151) || (c == 152)  || (c == 141) || (c == 171)  ||
        (c == 189) || (c == 190))
      ss += c;
    else if(ss != "")
    {
      cout << "[" << ss << "]\n";
      ss = "";
    }

Nie kompilowałem.

1 użytkowników online, w tym zalogowanych: 0, gości: 1