你真的能用C语言重新定义关键字吗?

你真的能用C语言重新定义关键字吗?,c,keyword,c-preprocessor,C,Keyword,C Preprocessor,你能解释一下下面的代码吗?我们如何使用#定义作为C关键字 #include <stdio.h> #define int int* int main(void) { int *p; int q; p = 10; q = 5; printf("%d %d", p, q); // your code goes here return 0; } 这个#define int*是一个预处理器宏。如果要为类型定义自己的同义词,请使用typ

你能解释一下下面的代码吗?我们如何使用
#定义
作为C关键字

#include <stdio.h>
#define int int*
int main(void) {

    int *p;
    int q;
    p = 10;
    q = 5;
    printf("%d %d", p, q);
    // your code goes here
    return 0;
}
这个
#define int*
是一个预处理器宏。如果要为类型定义自己的同义词,请使用
typedef
。不能使用未创建的语言创建关键字

样本:

#include <stdio.h>
typedef int * myIntPtr;

int main(void) {

    int i = 10;
    myIntPtr x = &i;
    printf("%d", *x);
    return 0;
}
在语义上把
int
转换成
int*
也没有意义

#define a b
将在#define之后将源中的所有“a”更改为“b”


这不是定义关键字。这是一个宏。你不能定义关键字。
#define int*
——男人们都是为较轻的罪行而死的。打开编译器警告。此代码是伪造的。
typedef
不只是创建同义词吗?我的意思是
int*
是预定义的,您将使用
typedef
的任何
struct
都必须由用户定义?@shree.pat18-是的,我的说法是误导性的-更正了它。
10
#define a b
#include <stdio.h>
#define int int*

int main(void) {
    int *p;
    int q;
    p = 10;
    q = 5;
    printf("%d %d", p, q);
    // your code goes here
    return 0;
}
int main(void) {
    int **p;
    int *q;
    p = 10;
    q = 5;
    printf("%d %d", p, q);
    // your code goes here
    return 0;
}