1 / 26

Menggunakan Fungsi String

Follow Blog : Aasliyaniunm10.wordpress.com. Menggunakan Fungsi String. Pertemuan 5. Fungsi Manupulasi String. Fungsi strcat () Fungsi strcmp () Fungsi strcpy () Fungsi strlen () Fungsi strrev (). Fungsi strcat ().

alamea
Télécharger la présentation

Menggunakan Fungsi String

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. FollowBlog : Aasliyaniunm10.wordpress.com MenggunakanFungsi String Pertemuan 5

  2. FungsiManupulasi String • Fungsistrcat() • Fungsistrcmp() • Fungsistrcpy() • Fungsistrlen () • Fungsistrrev()

  3. Fungsistrcat() Fungsistrcat(), digunakanuntukmenambahkan string sumberkebagianakhirdari string tujuan. Bentukpenulisan : Strcat(tujuan, sumber) ;

  4. Contoh # include<stdio.h> #include<conio.h> #include<iostream.h> Void main () { Char a1[20]; Char a2[20]; cout<<“masukkankata -1= “;

  5. count Cin>>a1; Cout,,”masukkankata – 2= “; Cin>>a2; Strcat (a1, a2) ; Cout<< “ hasilPenggabungannya “<<a1; getch() ; }

  6. Output Program

  7. Fungsistrcmp() Fungsistrcmp(), Untukmembandingkan string pertamadengan string kedua. Bentukpenulisan : Vaer_ int = strcmp (strl, str 2) ;

  8. Fungsistrcpy() Fungsistrcpy(), Untukmenyalin string asalkevariabel string tuuandengansyarat string tujuanharusmempunyaitipe data danukuran yang samadengan string asal Bentukpenulisan : Strcpy (tujuan, asal) ;

  9. Contoh # include<stdio.h> #include<conio.h> #include<iostream.h> Void main () { Char huruf [30]; Char pindah [30];

  10. Cout<<“masukkanSembarangkata = “; Gets (huruf); /*proses*/ Strcpy (pindah, huruf); Cout<<“pemindahannya = “<<pindah; Getch(); }

  11. Output Program

  12. Fungsistrlen () Fungsistrlen (), digunakanuntukmemperolehbanyaknyakarakterdalam string. Bentukpenulisan : Strlen (str) ;

  13. Contoh # include<stdio.h> #include<conio.h> #include<iostream.h> Void main () { char huruf [30];

  14. cout,<<“masukkansembarangkata = “; gets(huruf); Cout<<“panjangkata yang diinputkan = “; Cout<<sterlen(huruf); Caout<<“karakter”; Getch() }

  15. Output Program

  16. Fungsistrrev() Fungsistrrev() digunakanuntukmembalikletakurutanpada string. BentukPenulisan : Strrev (str) ;

  17. Contoh

  18. Output Program

  19. FungsiKonversi string • Fungsiatof(), untukmengubah string (teks) angakmenjadibilangannumerik float. • Fungsiatoi(), untukmengubah string (teks) angkamenjadibilangannumerik integer. • Fungsiatoi(), untukmengubah string (teks) angkamenjadibilangannumerik long integer.

  20. ContohFungsiatof(),

  21. Ouput Program

  22. ContohFungsiatoi(),

  23. Output Program

  24. ContohFungsiatoi(),

  25. Output Program

  26. TerimaKasih

More Related