How can I show code (specifically C++) in an HTML page?

前端 未结 3 1986
独厮守ぢ
独厮守ぢ 2021-02-05 14:51

How can I show code in a website using HTML? Basically, I have a C++ program that I\'d like to share on my website and I want to show it in the page.

Is there anyway to

3条回答
  •  日久生厌
    2021-02-05 15:49

    You can use SyntaxHighlighter. It will unobtrusively enhance code samples on your page with specific syntax highlighting for a wide range of languages.

    Here's an example for C++

    
      
      
    
    
    
      
      // my first program in C++
      #include 
      using namespace std;
    
      int main ()
      {
        cout << "Hello World!";
        return 0;
      }
      

提交回复
热议问题