1,代码的可读性:
(1) 我们先来看看简单的例子吧!
int test_fun(int c)
{
if( c < 0)
{
printf("input error\n");
return -1;
}
return 0;
{
#define OK 0
#define ERROR -1
int test_fun(int c)
{
if( c < 0)
{
printf("input error\n");
return ERROR;
}
return OK;
{
你觉得下面的代码好还是上面的代码好呢!
如果这个代码不足以说明问题,我们看一下下面这个问题:
typedef enum num
{
ZERO,
ONE,
TWO,
THREE,
FOUR
}NUM;
unsigned int test_fun(NUM nu)
{
switch(nu)
{
case ZERO:
printf("num = %d\n",nu);
return nu;
case ONE:
printf("num = %d\n