oke_google

Modul 3.3

Nov 29th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char input1[100];
  9.     char input2[100];
  10.     char cari;
  11.     cout<<"Status saya adalah ";
  12.     cin.getline(input1, 100);
  13.     cout<<"Saya adalah "<<input1<<" ";
  14.     cin.getline(input2, 100);
  15.     cout<<"Hasil perbandingan = "<<strcmp(input1, input2)<<endl;
  16.     cout<<"Panjang Karakter "<<input1<<" adalah "<<strlen(strcat(input1, input2))<<endl;
  17.     cout<<"Huruf yang anda cari pada kata "<<input1<<" = ";
  18.     cin>>cari;
  19.     char * letak;
  20.     letak=strchr(input1, cari);
  21.     while(letak!=NULL){
  22.     cout<<"Huruf "<<cari<<" ditemukan pada huruf ke-"<<int(letak-input1+1)<<endl;
  23.     letak=strchr(letak+1,cari);
  24.     }
  25. }
Add Comment
Please, Sign In to add comment