我在编译器的词法分析中遇到了一些问题,我声明了以下指针
char *words[29]={
"program",
"label",
"integer",
"word",
"char",
"byte",
"shortint",
"logint",
"real",
"single",
"double",
"string",
"boolean",
"var",
"procedure",
"function",
"begin",
"end",
"if",
"then",
"else",
"or",
"and",
"div",
"not",
"do",
"while",
"mod"
};
char message[30];
然后我尝试在函数中使用它
for(handle=0;(&words[handle] != NULL);handle++)
{
message = &words[handle];
if(!strcmp(token,message))
message='words';
}
但是我在尝试执行时收到以下错误:
关于 (line message = &words[handle];) : 警告 C4047: '=' : 'char [30]' 与 'char ** ' 的间接级别不同
关于 (line message = &words[handle];) : 错误 C2106: '=' : 左操作数必须是左值
关于 (line message='words';) : error C2015: too many characters in constant
关于(line message='words';):错误 C2106:'=':左操作数必须是左值
我不能那样使用指针吗?你有什么建议吗?