#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); }