帮忙看看这个程序的问题吧,谢谢

来源:百度知道 编辑:UC知道 时间:2024/09/21 18:59:33
统计一个C语言源程序文件中的标识符的个数的函数(主要是数组的问题)
void dmenu17(void)
{
char *keywords[] = {"auto", "char", "double", "float", "int", "long", "short"};
char a[100], *b[100][100];
int x = 0, m = 0, c;
int out = 0, in = 1, state1, state2;
state1 = state2 = out;
while( (c = getchar()) != EOF)
{
if ( c == ';' || c == '(' || c == ' ')
state2 = out;
if (!(c >= 65 && c <= 90 || c >= 97 && c<= 122) && state1 == in && state2 == in)
{
strcpy(b[m][100], a);
m++;
}
if (!(c >= 65 && c <= 90 || c >= 97 && c<= 122))
{
state1 = out;
x = 0;
}
else
state1 = in;
if (state1 == in)
{
a[x] = c;
a[x + 1] = 0;
x++;
}
for(int i = 0; i < 7; i++)
if (strcmp(a, keywords[i]) == 0)
{

#include <stdio.h>
#include <string.h>

int GetKeywordNumber(char *szKeyword[])
{
int n = 0;
for(int i = 0; szKeyword[i]; szKeyword ++, n++);

return n;
}
int main()
{
char szText[] = "int main(){ int a, int b; double c; c = 10; }";
char *szKeyword[] = {"auto", "char", "double", "float", "int", "long", "short", 0};
char szWord[100] = {0};
int nLen = strlen(szText) + 1, i = 0, j = 0;

int nKeyworNum = GetKeywordNumber(szKeyword);
int nKeyworNumber = 0;
for(; i < nLen; i++)
{
if( szText[i] != ' ' && szText[i] != 0 )
{
szWord[j] = szText[i];
j++;
}
else
{

j = 0;
bool bIsKeyword = false;
for(int k = 0; k < nKeyworNum; k++)
{
if( strcmp(szWord, szKeyword[k]) == 0 )