Hi experts,
Iam writing a file reading and manipulation program using c. What I have to do, is to read the keyword and valued froma file, delimetered with equal sign. Then I want to perform a string comparison of the keywords, adn then store the value of the corresponding keyword in to a structure. I will write program as belows...


int writestruct(char* keyword, char* keyvalue)
{

int i;
char *table []={"ID","NODE","UID","GID"..........81 items}
for (i=0; ; i++) {
if(!strcmp(keyword, table[i]))
break;
}
clrscr();
switch (i)
{
case 0 : strcpy(user.ID, keyvalue);break;
case 1 : strcpy(user.NODE, keyvalue);break;
case 2 : strcpy(user.UID,keyvalue);break;...............

}


The above function to write the corresponding vlaue to the keyword into structure user , which is previously defined.

***********************************************************************
Now the below function to return the value fro structure at a later time
************************************************************************
char* returnstruct(char* keyword)
{
char* szReturnstruct=malloc(100*sizeof(char));
int i;
char *table []={"ID","NODE","UID","GID"....81 items}

for (i=0; ; i++) {
if(!strcmp(keyword, table[i]))
break;
}
clrscr();
switch (i)
{
case 0 : strcpy(szReturnstruct,user.ID);break;
case 1 : strcpy(szReturnstruct,user.NODE);break;
case 2 : strcpy(szReturnstruct,user.UID);break;
case 3 : strcpy(szReturnstruct,user.GID);break;
}


Now the real problem is that in the for loop( used to return int value for case structure). Its taking a lot of cpu time and memory....... Can anyone devise another method ( hash table search and sorting algorithm implementation is preferred). to get rid of this performance criteria........Sample code will be greatly appreciated...


Note:
Sample codes of hash table searching and sorting is also appreciated.

Thanks in advance

MS