Code View
In the linked page u can see that source code is properly formated, how to do that??

I am making my web, i want to know that how can i show the c++ source code on my web with proper format.

Q: How to show a formated source code on a HTML Page.

Thanks.

Recommended Answers

Use <pre></pre> or <code></code> tags around it like:

<pre>
#include &lt;iostream&gt;
int main(int argc, char** argv)
{
  std::cout &lt;&lt; "Hello World!\n";
  return 0;
}
</pre>

Note the &lt; . Make sure you encode any HTML entities (<, >, &, etc.) so they don't get …

Jump to Post

All 2 Replies

Use <pre></pre> or <code></code> tags around it like:

<pre>
#include &lt;iostream&gt;
int main(int argc, char** argv)
{
  std::cout &lt;&lt; "Hello World!\n";
  return 0;
}
</pre>

Note the &lt; . Make sure you encode any HTML entities (<, >, &, etc.) so they don't get mixed in with the markup

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.