gpt4 book ai didi

c - 如何在 C 中使用字符串化在预处理器中执行计算

转载 作者:太空狗 更新时间:2023-10-29 15:04:30 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How to stringify an expression in C

我希望我能在这里找到我的问题的一些解决方案。

我想添加 ADD1 中定义的十六进制数字,需要将它们以字符串形式放入 *str 中。

This is only a example, to prove its possibility first. I am actually doing the same in a header file.

#include <stdio.h>


#define XMK_STR(x) #x
#define MK_STR(x) XMK_STR(x)
#define ADD1 0x6000+0x10

main()
{
char *str = "START " MK_STR(ADD1) "\n";
printf(str);
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com