Advertisement
nicuvlad76

Untitled

Nov 17th, 2020
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. char s[301], *p;///pointer la caractere=adresa la care se gaseste sirul s
  5. char sep[]=" ,.!:?";
  6. char cuv[101][301];///vector de cuvinte
  7. int n;
  8. int main()
  9. {
  10. ///strtok(sir, sep)
  11. ///impartirea in cuvinte
  12. cin.getline(s,300);
  13. p=strtok(s,sep);///inlocuieste toti separatori cu NULL
  14. while(p!=NULL)
  15. {
  16. ///cout<<p<<'\n';
  17. strcpy(cuv[++n],p);
  18. p=strtok(NULL,sep);///NULL sau 0
  19. }
  20. for(int i=1;i<=n;i++)
  21. cout<<cuv[i]<<'\n';
  22. return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement