Advertisement
Chieffo

klasy string

Oct 1st, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4.  
  5. int main()
  6.  
  7. {
  8. //getline(cin,dupa)//cin do stringów
  9.  
  10. //metody klasy string
  11. string dupa="dupa";
  12. string lel="lel";
  13. cout<<dupa.at(1)<<endl;//zwraca dany znak //u
  14. cout<<dupa.find('a')<<endl;//zwraca wartość położenia pierwszego znaku
  15. cout<<dupa.empty()<<endl;//zwraca true jeżeli pusty
  16. dupa.swap(lel);//zamienia miejscami
  17. cout<<dupa<<" "<<lel<<endl;//wypisuje zamienione
  18. dupa.swap(lel);//zamienia miejscami, odmienilem////
  19. cout<<dupa.substr(1,2)<<endl;//wypisuje od 2 znaku dwa znaki (wynik = up)
  20. cout<<dupa.append(" Oli")<<endl;//dołączenie łancucha znaków do tekstu
  21. cout<<dupa.erase(2)<<endl;//usuwa od danego znaku resztę znaków
  22. dupa.clear();//czyści tekst
  23. cout<<dupa<<endl;
  24.  
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement