private void 开始分析ToolStripMenuItem_Click(object sender, EventArgs e)
{
string[] keyword ={"auto","double","int","break","else","long","switch" ,"case" ,"register","typedef","char","extern","return ","union","const" ,"float" ,"short","unsigned","continue","for","signed","void","default",
"goto","sizeof","volatile","do","while","static" ,"if","printf"};//关键字/保留字
string[] operatorcharter = { "+", "-", "==", "*", "/", "<", ">", "<=", ">=", "=", "!=", "++", "--" };//运算符
string[] operatorinterface = { "(", ")", "[", "]", "{", "}", ",", ":", ";", "\"", "*/", "/*" };//介符
int i;
string[] a;
int k=0;
for (i = 0; i <= richTextBox1.Text.Length; i++)
{ int j = 0;
if (richTextBox1.Text[i] ="") break ;
else
while (richTextBox1.Text[i] !="") {
a[j] = richTextBox1.Text[i];
j++;
i++;
}
if (a[j] == keyword) { richTextBox2.Text = "k++ a[j] 关键字"; }
else if (a[j] == operatorcharter) { richTextBox2.Text = "k++ a[j] 运算符"; }
else if (a[j] == operatorinterface) { richTextBox2.Text = "k++ a[j] 介符"; }
else { richTextBox2.Text = "k a[j] 标识符"; }
}
}
【我想知道把单词或其他分析出来该怎么写】
------解决方案--------------------
搜索下盘古分词
------解决方案--------------------
这段代码你是哪里搞来的?运行过吗?是跑不通的吧,没有实例的对象a直接复制会数组越界的