poniedziałek, 11 listopada 2019

Text function and different types (C/C++ Builder)

UnicodeString __fastcall TForm1::first_and_Last(UnicodeString text_Ex)
{
wchar_t* date_Text=text_Ex.w_str();
int size_Text=wcslen(date_Text);
int size_Result=size_Text-2;
int i;
wchar_t* new_Text=new wchar_t[size_Result];
for(i=0;i<size_Result;i++)
new_Text[i]=date_Text[i+1];
return (UnicodeString) new_Text;
}
AnsiString __fastcall TForm1::first_and_Last2(AnsiString text_Ex)
{
char* date_Text=text_Ex.c_str();
int size_Text=strlen(date_Text);
int size_Result=size_Text-2;
int i;
char* new_Text=new char[size_Result];
for(i=0;i<size_Result;i++)
new_Text[i]=date_Text[i+1];
return (AnsiString) new_Text;
}

String __fastcall TForm1::first_and_Last3(String text_Ex)
{
char* date_Text;
sprintf(date_Text,"%s",text_Ex.c_str());
int size_Text=strlen(date_Text);
int size_Result=size_Text-2;
int i;
char* new_Text=new char[size_Result];
for(i=0;i<size_Result;i++)
new_Text[i]=date_Text[i+1];
return (String) new_Text;
}
string first_and_Last4(string text_Ex)
{
const char* date_Text=text_Ex.c_str();
int size_Text=strlen(date_Text);
int size_Result=size_Text-2;
int i;
char* new_Text=new char[size_Result];
for(i=0;i<size_Result;i++)
new_Text[i]=date_Text[i+1];
return (string) new_Text;
}
char* first_and_Last5(char* text_Ex)
{
const char* date_Text=text_Ex;
int size_Text=strlen(date_Text);
int size_Result=size_Text-2;
int i;
char* new_Text=new char[size_Result];
for(i=0;i<size_Result;i++)
new_Text[i]=date_Text[i+1];
return  new_Text;
}

Brak komentarzy:

Prześlij komentarz