AnAriyan

strTOk()

Oct 12th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6.    char w[10000];
  7.       char *word;
  8.     int t;
  9.     cin>>t;
  10.     int count = 0 ;
  11.     for (int i = 0 ; i < t; i++)
  12.     {
  13.           scanf(" %[^\n]",w);
  14.         //  cout <<w<<endl;
  15.          count = 0;
  16.           word = strtok(w,",!;?. ");
  17.          cout <<word<< " " <<w<<endl;
  18.         while(word!=NULL)
  19.         {
  20.             if(strlen(word)>0){
  21.             count++;
  22.             }
  23.           word =   strtok(NULL,",!;?. ");
  24.            cout<<word<< " " <<w<<endl;
  25.  
  26.         }
  27.  
  28.         cout<<"count : " << count<<endl;
  29.  
  30.     }
  31.  
  32.  
  33.  
  34. }
Add Comment
Please, Sign In to add comment