latest Post

Contoh fungsi string sederhana dengan C++

Berikut contoh fungsi string sederhana dengan menggunakan Dev-C++

#include <iostream>
#include <cstring>

using namespace std;

int main ()
{
char s1[6] = "ABCDE";
char s2[7] = "FGHIJK";
if (strcmp(s1,s2) < 0) cout << s1 << " < " << s2 << endl;
else cout << s1 << " >= " << s2 << endl;

   return 0;
}




#include <iostream>
#include <cstring>

using namespace std;

int main ()
{
   
char first[10]= "Teknologi";
char last[10] = "Informasi";

int n = strlen(first);
cout << strlen(first) << endl;
cout << strncpy(first,last,1)<< endl;
cout << strncat(first,last,3)<< endl;

   return 0;
}

About Unknown

Unknown
Recommended Posts × +

0 comments:

Post a Comment