Function using string produced from another function C++
<p>I had written a function , which is supposed to analyze and use the data (string to be specific) produced from another function and calculate the percentage of chars and print out the results.</p>

<p>this function is of type int but the previous function is of type string. I was thinking of using pointers but I don't know if it's a valid conversion.</p>

<p>I also don't believe that putting a function in another function argument is valid.</p>

<p>here is an almost complete function</p>

<pre><code>int percentages(string line)
{
    int overalcount;
    double Leu, Phe, Ile, STA, Val, Ser, Pro, Thr, Ala, Tyr, STO, His, Gln, Asn, Lys, Asp, Glu, Cys, Trp, Arg, Gly;
    int percentage, percentage1, percentage2, percentage3, percentage4, percentage5, percentage6, percentage7;
    int percentage8, percentage9, percentage10, percentage11, percentage12, percentage13, percentage14;
    int percentage15, percentage16, percentage17, percentage18, percentage19, percentage20;
    int i;

    for (i = 0; i + 3 &lt; line.length(); i += 3)
    {
        overalcount++;

        if(line.substr(i, 3) == "Phe")
        {
            Phe++;
            if(!Phe == 0)
            {
                percentage = (Phe / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Leu")
        {
            Leu++;
            if(!Leu == 0)
            {
                percentage = (Leu / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Ile")
        {
            Ile++;
            if(!Ile == 0)
            {
                percentage = (Ile / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "STA")
        {
            STA++;
            if(!STA == 0)
            {
                percentage = (STA / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Val")
        {
            Val++;
            if(!Val == 0)
            {
                percentage = (Val / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Ser")
        {
            Ser++;
            if(!Ser == 0)
            {
                percentage = (Ser / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Pro")
        {
            Pro++;
            if(!Pro == 0)
            {
                percentage = (Pro / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Thr")
        {
            Thr++;
            if(!Thr == 0)
            {
                percentage = (Thr / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Ala")
        {
            Ala++;
            if(!Ala == 0)
            {
                percentage = (Ala / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Tyr")
        {
            Tyr++;
            if(!Tyr == 0)
            {
                percentage = (Tyr / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "STO")
        {
            STO++;
            if(!STO == 0)
            {
                percentage = (STO / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "His")
        {
            His++;
            if(!His == 0)
            {
                percentage = (His / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Gln")
        {
            Gln++;
            if(!Gln == 0)
            {
                percentage = (Gln / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Asn")
        {
            Asn++;
            if(!Asn == 0)
            {
                percentage = (Asn / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Lys")
        {
            Lys++;
            if(!Lys == 0)
            {
                percentage = (Lys / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Asp")
        {
            Asp++;
            if(!Asp == 0)
            {
                percentage = (Asp / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Glu")
        {
            Glu++;
            if(!Glu == 0)
            {
                percentage = (Glu / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Cys")
        {
            Cys++;
            if(!Cys == 0)
            {
                percentage = (Cys / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Trp")
        {
            Trp++;
            if(!Trp == 0)
            {
                percentage = (Trp / overalcount) * 100;
            }
        }
        else if(line.substr(i, 3) == "Arg")
        {
            Arg++;
            if(!Arg == 0)
            {
                percentage = (Arg / overalcount) * 100;
            }   
        }
        else if(line.substr(i, 3) == "Gly")
        {
            Gly++;
            if(!Gly == 0)
            {
                percentage = (Gly / overalcount) * 100;
            }   
        }
    }

    if(!percentage == 0)
    {
        cout &lt;&lt; "Percentage of Phe: " &lt;&lt;percentage &lt;&lt;endl;
    }
    if(!percentage1 == 0)
    {
        cout &lt;&lt; "Percentage of Leu: " &lt;&lt;percentage1 &lt;&lt;endl;
    }
    if(!percentage2 == 0)
    {
        cout &lt;&lt; "Percentage of Ile: " &lt;&lt;percentage2 &lt;&lt;endl;
    }
    if(!percentage3 == 0)
    {
        cout &lt;&lt; "Percentage of STA: " &lt;&lt;percentage3 &lt;&lt;endl;         
    }
    if(!percentage4 == 0)
    {
        cout &lt;&lt; "Percentage of Val: " &lt;&lt;percentage4 &lt;&lt;endl;         
    }
    if(!percentage5 == 0)
    {
        cout &lt;&lt; "Percentage of Ser: " &lt;&lt;percentage5 &lt;&lt;endl;
    }
    if(!percentage6 == 0)
    {
        cout &lt;&lt; "Percentage of Pro: " &lt;&lt;percentage6 &lt;&lt;endl;
    }
    if(!percentage7 == 0)
    {
        cout &lt;&lt; "Percentage of Thr: " &lt;&lt;percentage7 &lt;&lt;endl;
    }
    if(!percentage8 == 0)
    {
        cout &lt;&lt; "Percentage of Ala: " &lt;&lt;percentage8 &lt;&lt;endl;
    }
    if(!percentage9 == 0)
    {
        cout &lt;&lt; "Percentage of Tyr: " &lt;&lt;percentage9 &lt;&lt;endl;
    }

    return 0;
}
</code></pre>

<p>the argument "string line" is supposedly the string produced by the previous function. But it is instead recognizing the line that is read from the input filestream.</p>
