How to add c++ code in WordPress.com post

I am trying to add some c++ code in WordPress post, but some character become &lt/&amp/&gt.

How can I solve this problem?

Read More

I tried the following:

[sourcecode language="cpp" title="Code:"]
void build_LCP_array(void)
{
    LCP[0] = 0;
    int n = text.size(), i, j, id1, id2;
    for(i = 1; i < n; i++)
    {
        id1 = arr[i - 1].indx;
        id2 = arr[i].indx;
        LCP[i] = 0;
        for(j = step - 1; j >= 0; j--)
            if(Rank[j][id1] == Rank[j][id2] && Rank[j][id2])
            {
                LCP[i] += (1 << j);
                id1 += (1 << j);
                id2 += (1 << j);
            }
    }
}
[/sourcecode]

And Result:

void build_LCP_array(void)
{
    LCP[0] = 0;
    int n = text.size(), i, j, id1, id2;
    for(i = 1; i &lt; n; i++)
    {
        id1 = arr[i - 1].indx;
        id2 = arr[i].indx;
        LCP[i] = 0;
        for(j = step - 1; j &gt;= 0; j--)
            if(Rank[j][id1] == Rank[j][id2] &amp;&amp; Rank[j][id2])
            {
                LCP[i] += (1 &lt;&lt; j);
                id1 += (1 &lt;&lt; j);
                id2 += (1 &lt;&lt; j);
            }
    }
}

Related posts

Leave a Reply

2 comments