#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
cout<<"FUNGSI-FUNGSI DALAM STRING" <<endl;
cout<<endl;
cout<<"1. Inisialisasi string :" <<endl;
char kalimat[50]="Aku Sayang Kamu";
cout<<kalimat;
cout<<endl;
cout<<endl;
cout<<"2. Membaca string dari keyboard :"<<endl;
char nama[50];
cout<<"Nama :";
cin.getline(nama,sizeof(nama));
cout<<endl;
cout<<endl;
cout<<"3. Mengkopy string :" <<endl;
char kata1[30]="aku sayang kamu";
char kata2[40]="aku cinta kamu";
strcpy(kata1,kata2);
cout<<kata2;
cout<<endl;
cout<<endl;
cout<<"4. Fungsi strlen :"<<endl;
char kata[100]="Jangan tinggalkan aku";
int i=strlen(kata);
cout<<i;
cout<<endl;
cout<<endl;
cout<<"5. Fungsi strcat :"<<endl;
char cinta1[54]="Jangan Marah";
char cinta2[67]="Jangan sedih";
strcat(cinta1,cinta2);
cout<<cinta1;
cout<<endl;
cout<<endl;
cout<<"6. Fungsi strupr :" <<endl;
char string[90]="aku makan mangga";
strupr(string);
cout<<string;
cout<<endl;
cout<<endl;
cout<<"7. Fungsi strlwr :" <<endl;
char makan[40]="KUMERINDUKANMU";
strlwr(makan);
cout<<makan;
cout<<endl;
cout<<endl;
cout<<"8. Fungsi strstr :" <<endl;
char aku1[56]="Kamu dalam kenanganku";
char aku2[78]="Ku slalu mengharapkanmu";
strstr(aku1,aku2);
cout<<aku1;
cout<<endl;
cout<<endl;
cout<<"9. Fungsi strrev :" <<endl;
char kamu[78]="Cinta";
strrev(kamu);
cout<<kamu;
cout<<endl;
cout<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
Tidak ada komentar:
Posting Komentar