Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

generating HTML that depicts C++ code

Posted on 2000-04-04
1
Medium Priority
?
212 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 200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.

783 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