Advertisement
a53

StrToc

a53
Dec 27th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. int main()
  5. {
  6. char a[100],cuv[100][20],*p,separator[]=" ,;:";
  7. cout<<"Dati sirul:";
  8. cin.get(a,100);
  9. p=a;
  10. p=strtok(p,separator);
  11. int nr=0;
  12. while(p)
  13. strcpy(cuv[++nr],p),p=strtok(NULL,separator);
  14. cout<<"Sunt "<<nr<<" cuvinte:"<<'\n';
  15. for(int i=1;i<=nr;++i)
  16. cout<<cuv[i]<<'\n';
  17. return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement