Switch to full style
HTML code examples
Post a reply

display code block using html

Fri Feb 24, 2012 10:48 pm

In the following example we use CSS properties with samp tag to display C++ computer code.

Code:



<html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>Display computer code</title>
<
style type="text/css">
samp.code{
  
background#EEE;
  
border2px groove red;
  
color#111;
  
padding6px;
  
width300px;
  
displayblock;
}

</
style>
</
head>

<
body>
<
p><samp class="code">
      
std::vector<std::vector<double> > rawdata(3);<br/>
    
int datapts readdata_NxM(argv[4], rawdata);<br/>
    if (
datapts <= 0) {<br/>
        
std::cerr << "Error reading data from file \n" << argv[4] << std::endl;<br/>
        
usage(argv[0]);<br/>
    }<
br/>
<
br/>
    
// convert from Nx3 matrix to individual vectors. Not very elegant...<br/>
    
doublexpos = &rawdata[0][0];<br/>
    
doubleypos = &rawdata[1][0];<br/>
    
doubleclst = &rawdata[2][0];<br/>
    
doubleweights = &weightdata[0][0];<br/>

<
br/>
</
samp></p>

</
body>
</
html>

 




Post a reply
  Related Posts  to : display code block using html
 read php file in asp and display it as html     -  
 I need help with a html code     -  
 How to link a c++ program with HTML code     -  
 threads block on I/O     -  
 braces block inside your class     -  
 .aspx render block results (response.write, <%=     -  
 Here is how to display any 2d array     -  
 display list     -  
 SEVEN SEGMENT DISPLAY     -  
 Display a different image for each day of the week     -  

Topic Tags

HTML SAMP