Help in combining two functions in c++
<p>I am just trying something with somebody else's code.</p>

<p>I have two functions:</p>

<pre><code>int Triangle(Render *render, int numParts, Token *nameList, Pointer *valueList) 
    int i;
    for (i=0; i&lt;numParts; i++)
    {
        switch (nameList[i])
        {
        case GZ_NULL_TOKEN:
            break;

        case GZ_POSITION:
            return putTrianglePosition(render, (Coord *)valueList[i]);
            break;
        }
    }

    return SUCCESS;
}

int putTrianglePosition(Render *render, Coord vertexList[3]) /*vertexList[3][3:xyz]*/
{
    Coord *pv[3];
    int i,j;

    // sort verts by inc. y and inc. x
    pv[0] = &amp;vertexList[0];
    pv[1] = &amp;vertexList[1];
    pv[2] = &amp;vertexList[2];
    for (i=0; i&lt;2; i++)
        for (j=i+1; j&lt;3; j++)
        {
            if ((*pv[i])[1]&gt;(*pv[j])[1] || 
                (*pv[i])[1]==(*pv[j])[1] &amp;&amp; (*pv[i])[0]&gt;(*pv[j])[0]) {
                Coord *tmp;
                tmp = pv[i];
                pv[i] = pv[j];
                pv[j] = tmp;
            }
        }
    ;

    // all y the same?
    if ((*pv[0])[1] == (*pv[2])[1]) {
        drawHorizonLine(render, *pv[0], *pv[2]);
        return SUCCESS;  
    }

    // assign middle point
    Coord mid; 
    mid[1] = (*pv[1])[1];   // y
    float ratio = ((*pv[1])[1] - (*pv[0])[1]) / ((*pv[2])[1] - (*pv[0])[1]);
    mid[0] = (*pv[0])[0] + ratio * ((*pv[2])[0] - (*pv[0])[0]); // x
    mid[2] = (*pv[0])[2] + ratio * ((*pv[2])[2] - (*pv[0])[2]); // z

    if (mid[0]&lt;=(*pv[1])[0]) {  // compare X
        drawTrapzoid(render, *pv[0], mid, *pv[0], *pv[1]); // upper tri
        drawTrapzoid(render, mid, *pv[2], *pv[1], *pv[2]); // lower tri
    }else{
        drawTrapzoid(render, *pv[0], *pv[1], *pv[0], mid); // upper tri
        drawTrapzoid(render, *pv[1], *pv[2], mid, *pv[2]); // lower tri
    }

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

<p>I don't want two functions here. I want to copy the <code>putTrianglePosition()</code> function into the <code>Triangle()</code> function.</p>

<p>I tried doing that, but I got a lot of errors.</p>

<p>Can somebody else show me how to do this?</p>
