How do I use the Chr() function in C++ Builder?

Asked

Viewed 282 times

1

I need an example of using the function Chr() or something equivalent in C++ Builder.

I’m needing to do a function to decrypt the database password.

  • Why do you want to use this function? It is part of Delphi, wouldn’t it be better to use C++ own things? Show what you’re doing to see if there’s a better solution.

  • I actually misposed the question. It could be something equivalent to this function, only in C++.

2 answers

1


C++ is different from Delphi in this respect. The type char in C++ is both a numeric and text type. You can both store in a variable char the textual representation of the character (with single quotes) how to use a simple number (usually equivalent to a single byte). Then the conversion is not necessary. Save the number you would pass to the function Chr() and you will already obtain the desired character. Thus:

char x = 65; //é o caractere A

Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.

Obviously where there is a literal number can be a variable or expression that results in this number.

If you want to use a multi-byte character, the most suitable type is the wchar_t.

0

Follow the function result to decrypt.

String DesprotegeSenhaSQL(String senha)
{
int i, j;
String aux, texto;

j=1;
for(i=1; i<=senha.Length();i++)
{
    if (senha.SubString(i,1)!="-" && senha.SubString(i,1)!="#")
    {
      aux = aux+senha.SubString(i,1);
    }
    else
    {
       try {
         texto=texto+char(StrToInt(aux)-j);
       } catch(Exception &ex)
       {
        exit;
       }
       j=j+1;
       aux="";
    }
 }
return texto;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.