Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to show c++ code in html?

Tags:

c++

html

When used with <pre> tag still it is not displaying <iostream.h>, <conio.h> and other keywords that contain <> angle brackets like "cout<<". I only want to know how to display my coding on webpage. (no compilation, no syntax highlighting)

like image 983
Sukhraj Avatar asked Mar 17 '23 11:03

Sukhraj


1 Answers

You need to replace < and > with their HTML character entity equivalents: &lt; and &gt;.

For example:

<pre>
  &lt;iostream.h&gt;
  &lt;conio.h&gt;
  cout&lt;&lt;
</pre>
like image 156
James Donnelly Avatar answered Mar 28 '23 18:03

James Donnelly