最近看代码时,发现宏定义时就对整数进行了数据类型定义,其实也是对宏定义的数据类型进行了定义。

(1)定义为int型

#include <stdio.h>
#include <stdlib.h>
# define MAX ((int)4)

void main()
{
	printf("MAX = %d.\n", sizeof(MAX));	
	system("pause");
}

运行结果
宏定义时对整数进行数据类型定义

(2)定义为char型

#include <stdio.h>
#include <stdlib.h>

# define MAX ((char)4)

void main()
{
	printf("MAX = %d.\n", sizeof(MAX));
	
	system("pause");
}

运行结果
宏定义时对整数进行数据类型定义

——————————
2019.01.09
22:20

相关文章:

  • 2021-07-31
  • 2021-06-08
  • 2021-07-30
  • 2021-12-30
  • 2021-08-05
  • 2021-07-28
  • 2021-07-14
猜你喜欢
  • 2022-12-23
  • 2021-10-22
  • 2021-10-31
  • 2021-08-29
  • 2021-06-11
相关资源
相似解决方案