Not the exact solution but you can refer this program to get your job done.
#include<stdio.h>
#include<string.h>
void getSubString(char *ptr,int i);
int getSum(char *ptr,char *temp,int i);
main()
{
char str[100];
printf("Enter a string : ");
scanf("%[^\n]",str);
int i=0,sum=0;
while(str[i])
{
str[i]=toupper(str[i]);
i++;
}
char subStr[10];
for(i=0;i<10;i++)
{
getSubString(subStr,i);
sum=sum+getSum(str,subStr,i);
}
printf("SUM = %d\n",sum);
}
int getSum(char *ptr,char *subPtr,int num)
{
char *temp=NULL;
int sum=0;
while(*ptr)
{
temp=strstr(ptr,subPtr);
if(temp==NULL)
return sum;
sum=sum+num;
ptr=temp;
ptr++;
}
return sum;
}
void getSubString(char *ptr,int i)
{
switch(i)
{
case 0:
strcpy(ptr,"ZERO");
break;
case 1:
strcpy(ptr,"ONE");
break;
case 2:
strcpy(ptr,"TWO");
break;
case 3:
strcpy(ptr,"THREE");
break;
case 4:
strcpy(ptr,"FOUR");
break;
case 5:
strcpy(ptr,"FIVE");
break;
case 6:
strcpy(ptr,"SIX");
break;
case 7:
strcpy(ptr,"SEVEN");
break;
case 8:
strcpy(ptr,"EIGHT");
break;
case 9:
strcpy(ptr,"NINE");
break;
default:
break;
}
}