假如现在要开发一个C语言程序,让它输出红色的文字,并且要求跨平台,在 Windows 和 Linux 下都能运行,怎么办呢?这个程序的难点在于,不同平台下控制文字颜色的代码不一样,我们必须要能够识别出不同的平台.Windows 有专有的宏_WIN32,Linux 有专有的宏__linux__,以现有的知识,我们很容易就想到了 if else,请看下面的代码: #include <stdio.h> int main(){ if(_WIN32){ system("color 0c&quo
#ifdef预编译相关用法主要有:(1)#ifdef XXX executing the corresponding xxx code #endif(2)#ifdef XXX executing the corresponding xxx code #else executing the other code(3)#ifdef XXX executing the corresponding xxx code #elif defined YYY executing the correspondin