1. ## comparing chars

hii
i want to compare 2 words... compare each letter
i don't want to use strcmp ..this is the function
Code:
```int WordCompare(char *pFirst,char *pSecond){
char *p1=pFirst,*p2=pSecond;int sum=0;
if(WordLength(p1)!=WordLength(p2))
return 0;
else
while(isalpha(*p1)){
if(*p1==*p2)       // <== here is my problem..
sum=sum+1;
p1++; p2++;
}
if(sum==WordLength(p1))
return 1;
}```

2. Code:
`if(*p1==*p2)       // <== here is my problem..`
What kind of a problem ?
Kurt

3. ## jaxlle

agin... i want to know how we compare 2 chars??
"jaxlle"

"jaxlle"

j=j
a=a
..............

4. Code:
```size_t size1 = strlen(str1);
size_t size2 = strlen(str2);
int i,j;

for(i=0;i < size1;i++)
for(j=0;j < size2; j++)
if(str1[i] == str2[j])```
there are lot of post on this topic on the board. U could just search the board for the solution. But here u go to start you.

ssharish2005

5. > for(i=0;i < size1;i++)
> for(j=0;j < size2; j++)
That's not it at all - that's more like strstr, not strcmp

You want to advance a subscript at the same rate along both strings.
say
for ( i = 0 ; i < size1 && i < size2 ; i++ )

6. Originally Posted by Salem
> for(i=0;i < size1;i++)
> for(j=0;j < size2; j++)
That's not it at all - that's more like strstr, not strcmp

You want to advance a subscript at the same rate along both strings.
say
for ( i = 0 ; i < size1 && i < size2 ; i++ )
Salem i throught the same way before this code which i posted. This was my first code which i was suppose to post.

Code:
`for(i=0; str1[i] != '\0' && str2[i] != '\0;i++)`
And i throught what if one string is less than the other and the compare stops inbetween. So i replaced it with the other which i posted. But u are right it much like strstr rather than to be strcmp

ssharish2005