簡體   English   中英

如何獲得降價以正確格式化此代碼?

[英]How can I get markdown to format this code properly?

這是一些我無法在markdown中正確設置格式的代碼,這是直接的C代碼,使用“ 4個空格”格式粘貼到文本框中以表示代碼:

#define PRINT(x, format, ...) \
if ( x ) { \
    if ( debug_fd != NULL ) { \
        fprintf(debug_fd, format, ##__VA_ARGS__); \
    } \
    else { \
        fprintf(stdout, format, ##__VA_ARGS__); \
    } \
}

似乎'\\'導致換行符被忽略。 好的,我已經習慣了bash,但是如果我輸入'\\',第二個不會出現。 好像第二個被吸收了。 我想念什么嗎?

在代碼的每一行之前至少添加四個空格或一個硬標簽。 像這樣:

#define PRINT(x, format, ...) \
if ( x ) { \
    if ( debug_fd != NULL ) { \
        fprintf(debug_fd, format, ##VA_ARGS); \
} \
else { \
    fprintf(stdout, format, ##VA_ARGS); \
} \
}

您還可以連續使用HTML標記<pre> <code>。 我發現將代碼粘貼到窗口中比較容易。

#define PRINT(x, format, ...)
if ( x ) 
{
    if ( debug_fd != NULL ) 
    { 
        fprintf(debug_fd, format, ##VA_ARGS); 
    } 
    else 
    { 
        fprintf(stdout, format, ##VA_ARGS); 
    } 
}

#define PRINT(x, format, ...)
if ( x ) 
{
    if ( debug_fd != NULL ) 
    { 
        fprintf(debug_fd, format, ##VA_ARGS); 
    } 
    else 
    { 
        fprintf(stdout, format, ##VA_ARGS); 
    } 
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM