Beberapa Fungsi string dalam c++
Fungsi String (strlen) #include<string.h> #include<conio.h> #include<iostream.h> main() {char kata[10]; int pjg; cout<<"kata : "; cin>>kata; pjg =(strlen(kata)); cout<<"panjang karakter : "<<pjg; }
Fungsi String (strcat) #include<string.h> #include<conio.h> #include<iostream.h> main() {char kt1[10], kt2[10]; cout<<"kata 1 : "; cin>>kt1; cout<<"kata 2 : "; cin>>kt2; cout<<strcat(kt1,kt2); }
Fungsi String (strcpy) #include<string.h> #include<conio.h> #include<iostream.h> main() { char kt1[10], kt2[10]; cout<<"kata 1 : "; cin>>kt1; strcpy(kt2,kt1); cout<<"kata 2 : "<<kt2; }
Fungsi String (strrev) #include<string.h> #include<conio.h> #include<iostream.h> main() {char kata[20]; cout<<"masukkan sembarang kata = "; cin>>kata; strrev(kata); cout<<"hasil perubahan = "<<kata; }
Fungsi String (strchr) #include<string.h> #include<conio.h> #include<iostream.h> main() {char *kalimat = "ujian akhir semester"; char *p; p=strchr(kalimat,'m'); cout<<"hasil = "<<p; }