mu_tou_man

导航

 
#include <iostream>
using namespace std;
char const *keyword[]={"do","for","switch","return","while"};
int lookup_keyword(const char * const des,char const *keyword_table[],int constsize)
{	
	const char **kwp;
	for (kwp=keyword_table;kwp<keyword_table+constsize;kwp++)
	{
		if (strcmp(*kwp,des)==0)
		{
			return kwp-keyword_table;
		}
	}
	return -1;
}

void main()
{
	cout<<lookup_keyword("while",keyword,5);
}

  

posted on 2014-10-05 10:16  mu_tou_man  阅读(122)  评论(0编辑  收藏  举报