Find Here !!!

Monday, 2 June 2014

Fungsi-fungsi string di C++

#include "iostream.h"
 #include "string.h"
 #include "stdio.h"


 main ()
 {
 char ulang;
char s[30];
char a[30];
char d[30];
char f[30];

g:

 cout<<"masukkan nama : ";gets (a);
  cout<<"masukkan nama : ";gets (s);

  cout<<" kata 1 : "<<strcpy (d,a)<<endl;
  cout<<" kata 2 : "<<strcpy (f,s)<<endl;
  cout<<" jumlah kar 1 : "<<strlen (a)<<endl;
  cout<<" jumlah kar 2 : "<<strlen (s )<<endl;
cout<<" huruf kecil 1 : "<<strlwr (a )<<endl;
cout<<" huruf kecil 2 : "<<strlwr (s )<<endl;
cout<<" huruf besar 1 : "<<strupr (a )<<endl;
cout<<" huruf besar 2 : "<<strupr (s )<<endl;

  cout<<"dibalik 1 : "<<strrev (a)<<endl;
 cout<<"dibalik 2 : "<<strrev (s)<<endl;
strrev (a)   ;
strrev (s);
 cout<<"hasil : "<<strcat (d,f)<<endl;

  cout<<endl<<"      mau ulang ?";
  cin>>ulang;
 if (ulang=='y'||ulang=='Y')
 goto g;
 else
 cout<<"berakhir";
  }


No comments:

Post a Comment