Q:

Declare int variable aux a.length = (); Or use o.length () in all loops?

I wonder which is faster: Say I'm working with some text (30 characters), which would be better? And with a lot of text which would be better?
1-
int tam = text.length();
for(int i=0;i<tam;i++)
{
    //something here//
}

2-
for(int i=0;i<a.length();i++)
{
    //something here//
}

and also comparing these two:
1-
        for (int i = 0; i < b.length(); i++)
        {
            aux = a.find(b[i]);
            if (aux == -1)
            {
                sucess = 0;
                break;
            }
            else
            {
                a.erase(aux,1);
            }
        }

2-
        for (int i = 0; i < b.length(); i++)
        {
            if (a.find(b[i]) == -1)
            {
                sucess = 0;
                break;
            }
            else
            {
                a.erase(a.find(b[i]),1);
            }
        }

A:

Both first are the better approach.
On the first example you are checking if i<a.length() is true on every cycle. That means that you are going to execute a.length() for every iteration. If the variable a is not changed, it is unnecessary and the better approach is to calculate before and use that value.
Note that if the variable a is changed inside, placing i<a.length() might be the correct approach. It depends on your problem.
On the second example it is the same basics. You avoid useless calculations because you won't need to calculate a.find(b[i]) again inside the else.

