小编Vis*_*ath的帖子

C中宏的范围?

如何评估这些宏?

# define i 20
void fun();

int main(){
  printf("%d",i);
  fun();
  printf("%d",i);
  return 0;
}

void fun(){
  #undef i
  #define i 30
}
Run Code Online (Sandbox Code Playgroud)

提供输出为2020但是,

# define i 20
void fun(){
  #undef i
  #define i 30
}

int main(){
  printf("%d",i);
  fun();
  printf("%d",i);
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出为3030.请解释.谢谢.

c c-preprocessor

28
推荐指数
5
解决办法
7958
查看次数

标签 统计

c ×1

c-preprocessor ×1