题
这是一些我无法在 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 中已经习惯了这一点,但是如果我输入 '\',第二个就不会出现。仿佛第二个被吸收了。我错过了什么吗?
解决方案
您还可以连续使用 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); \
} \
}
#define PRINT(x, format, ...)
if ( x )
{
if ( debug_fd != NULL )
{
fprintf(debug_fd, format, ##VA_ARGS);
}
else
{
fprintf(stdout, format, ##VA_ARGS);
}
}
不隶属于 StackOverflow