C语言中的奇怪指针问题
我有以下代码:C语言中的奇怪指针问题,c,pointers,C,Pointers,我有以下代码: #define MIN(a,b) (a <= b ? a : b) void main() { int a = 5; int* p = &a; int result = MIN(*p++,12); printf("%i",result); } #定义最小值(a,b)(a此行: int result = MIN(*p++,12); 扩展到: int result = (*p++ <= 12 ? *p++ : 12);
#define MIN(a,b) (a <= b ? a : b)
void main()
{
int a = 5;
int* p = &a;
int result = MIN(*p++,12);
printf("%i",result);
}
#定义最小值(a,b)(a此行:
int result = MIN(*p++,12);
扩展到:
int result = (*p++ <= 12 ? *p++ : 12);
^^^^ ^^^^
这一行:
int result = MIN(*p++,12);
扩展到:
int result = (*p++ <= 12 ? *p++ : 12);
^^^^ ^^^^
这一行:
int result = MIN(*p++,12);
扩展到:
int result = (*p++ <= 12 ? *p++ : 12);
^^^^ ^^^^
这一行:
int result = MIN(*p++,12);
扩展到:
int result = (*p++ <= 12 ? *p++ : 12);
^^^^ ^^^^
rand
有一次出现类似问题。声明了一个MIN
宏,并将rand()
用作参数之一。我花了几个小时才意识到rand
函数被调用了两次。有一次rand
出现类似问题。声明了一个MIN
宏,并使用了rand()
作为参数之一。我花了几个小时才意识到调用了两次rand
函数。有一次rand
出现类似问题。声明了MIN
宏,并使用了rand()
作为参数之一。我花了几个小时才意识到调用了两次rand
函数。有一次rand
出现类似问题。声明了一个MIN
宏,并使用rand()
作为参数之一。我花了几个小时才意识到调用了两次rand
函数。