Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>//jest potrzebna ale nie operuje charami
- using namespace std;
- int main()
- {
- char tekst[255];
- char napis[]="Ala ma kota";
- cout<<strstr (napis,"ma")<<endl; //wypisuje od wyrazu ma
- cout<<strlen(napis)<<endl; //ilośc znakow
- cout<<strcat(napis,"!")<<endl; //dodaje do łańcucha znaków !
- cout<<strncpy(tekst,napis,3)<<endl; //kopiuje 3 pierwsze znaki z napis do tekst
- cout<<strcmp(napis,tekst)<<endl; //porównuje jeżeli pierwszy jest dłuższy to zwraca 1 a jeżeli na odwrót to zwraca -1 jak 0 to są takie same
- cout<<strncmp(napis,tekst,3)<<endl<<endl; //porównuje 3pierwsze znaki obu tekstów i zwraca takie same wartości jak wyżej
- cout << tekst << ", " <<napis ;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement