Translasi 6.8. Mencoba strcpy
#include <iostream.h>
#include <string.h>
typedef char *string;
string copy(string str, int dari, int panjang)
{ char buf[50];
strcpy(buf,str+dari-1);
buf[panjang] = 0;
return buf;
}
void main()
{ char *kata="Algoritma", *hasil;
hasil = copy(kata, 3, 5);
cout << "Hasil copy : " << hasil;
}
No comments:
Post a Comment