SysUtilsStrMove (C++)
Description
This example shows two functions that have the same effect as StrNew and StrDispose.
char * AHeapaString(char *S) {
Allocate string on heap. if ((S != NULL) && (S[0] != '\0')) { int L = StrLen(S) + 1; char *p = (char *)malloc(L); return StrMove(p, S, L); } return NULL;
}
Code
void DisposeDaString(char *S)
{
// Dispose string on heap
if (S != NULL)
free(S);
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
char *S = "Now you see it.";
char *otherS = AHeapaString(S);
Canvas->TextOut(5, 10, otherS);
Canvas->Refresh();
Sleep(5000);
DisposeDaString(otherS);
}
Uses
- System.SysUtils.StrMove ( fr | de | ja )