Solved

generating HTML that depicts C++ code

Posted on 2000-04-04
1
204 Views
Last Modified: 2011-09-20
Is there a program that generates nicely formatted HTML that depicts C++ code?

i.e. I have a C++ code fragement that looks like:
    void userCode(Fred& x, Fred& y)
    {
      x = y;   // Could be self-assignment if &x == &y
    }
   
And the program should generate the following HTML:
<tt><br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;void&nbsp;userCode(Fred&amp;&nbsp;x)<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x&nbsp;=&nbsp;x;&nbsp;&nbsp;&nbsp;</tt><em>//&nbsp;Self-assignment</em><tt><br>
&nbsp;&nbsp;&nbsp;&nbsp;}
</tt>

I suppose the main issues is you have to force spaces (&nbsp) for all indents and do a line break (<br>) for each line.

If anyone knows of a utility that is already out there, it would be most helpful.
0
Comment
Question by:VEngineer
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 2686417
Simply embrace the C++ code with the <pre> HTML tag.

<pre>
void userCode(Fred& x, Fred& y)
{
    x = y;   // Could be self-assignment if &x == &y
}
</pre>
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now