"Kenny McCormack" <ga*****@yin.interaccess.com> wrote in message
news:dd**********@yin.interaccess.com...
Please help. Send answer to ne****@india.com
#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
ptrdiff_t sval(const char *s)
{
const char a[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
size_t v = 0;
const char *f = 0;
while(*s)
if(f = strchr(a, *s++))
v += f - a + 1;
return v;
}
size_t diff(const char *s1, const char *s2)
{
return (ptrdiff_t)fabs(sval(s1) - sval(s2));
}
int main()
{
const char comp1[] = "the sun";
const char comp2[] = "the moon";
printf("The difference betweeen %s and %s is %lu\n",
comp1, comp2, (unsigned long)diff(comp1, comp2));
return 0;
}
-Mike