How to show C ++ code in html?

When used with a tag, <pre>

it still does not display <iostream.h>

, <conio.h>

and other keywords that contain angle brackets <>

like " cout<<

". I only want to know how to display my coding in a webpage. (no compilation, syntax highlighting)

+3


source to share


1 answer


You need to replace <

and >

their characters the HTML : &lt;

and &gt;

.

For example:



<pre>
  &lt;iostream.h&gt;
  &lt;conio.h&gt;
  cout&lt;&lt;
</pre>
      

Run codeHide result


+7


source







All Articles