我想使用用户给定的输入字符串和值在函数内部定义一个预处理器。
#include<stdio.h>
void main()
{
char st[10];
int a;
printf("Enter string:");
scanf("%s",st);
printf("Enter Value:");
scanf("%d",&a);
//Here I want to define a preprocessor using input values.
//Suppose input given is HELLO and 3 I should define as #define HELLO 3 and use it later in the function.
}
有没有什么办法可以做到这一点。
我不确定它是如何完成的。无法从许多来源找到任何可能的帮助。用户根据预处理器的变化提供输入字符串和值。 如果我给 "MSG1" 和 12 我应该能够创建像 #define MSG1 12 或者如果用户给出“MSG2”和 13 然后#define MSG2 13。 希望这个问题清楚并且可以理解我期望实现的目标。任何建议都让我知道。提前致谢。