I am trying to add some c++ code in WordPress post, but some character become </&/>.
How can I solve this problem?
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 < 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);
}
}
}
According to here: http://en.support.wordpress.com/code/posting-source-code/ , you should use
Try this plugin too: https://wordpress.org/plugins/syntaxhighlighter/
I found a better way to post code in WordPress using gist.
Create a public gist of your code, and copy the source link and paste to WordPress content.