I think something is wrong with my Flames project.. please help me

the wrong might have been the counting.. example

Rizal
maria

I crossed out the similar letter and it came out that it had only three letters that are not similar so in F L A M E S -- it should be "A" for affection but in my code it came out that it is seven and its in "F" for friends what might be the wrong?

#include<stdio.h>
#include<conio.h>
#include<string.h>

void main() {
char str1[20];
char str2[20];
int x,y,z,flames,counter1,counter2,points=0;

clrscr();
printf ("enter your name here: ");
gets(str1);

printf ("Enter your crush's name:");
gets(str2);

counter1=strlen(str1);
counter2=strlen(str2);

for (x=0; x<counter1; x++){
for (y=0; y<counter2; y++){
if (str1[x]==str2[y])
points++;
else;
}

if(points!=0)
points++;
}

for (z=1; z<counter1; z++) {
if (str1[0]==str1[z])
points++;
else;
}

printf ("the points is %d \n",points);

flames=points%6;
switch(flames)

{
case 1: printf ("\n you're Friends"); break;
case 2: printf ("\n you're Lovers"); break;
case 3: printf ("\n you're Affection"); break;
case 4: printf ("\n you're Marriage"); break;
case 5: printf ("\n you're Enemies"); break;
case 0: printf ("\n you're sweethearts"); break;
}



getch();
}

You need to put a proper logic for finding the number of unmatched character.

Try out these changes :
1. Combine the two names to a single one and logic will be much easier to implement. (say in an array 'str3')
2. Change the logic to find the unmatched characters as :

for (x = 0; x < strlen(str3); x++)
{
    for (y = 0; y < strlen(str3); y++)
    {
        if(x == y)
            continue;
        if (str3[x] == str3[y])
            break;
    }
    if(y == strlen(str3))
        points++;
}

3. So, the final "for loop" (with loop variable 'z') is not required anymore.
That will make it to work I suppose. Post for any doubts.
Hope you dont land up to any "enemies" ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.