I am going to show you a working version of what your game might be like. I am not familiar with the game but it sounds like a game we use to play in school where you made a little toy out of paper, wrote colors, numbers etc on the pieces and a person would make choices to tell their fortune.
In the game below I have made a few modifications that you might want to take and use in the HOPE game. I first collect the names, add their lengths together and divide (modulus) the sum by 6 to get one of the fortunes in the switch statement.
So basically you enter "Tom" and "Brandy" and get "Marriage". Which comes out to Tom (3) + Brandy (6) = 9 % 6 = 3, number 3 is "marriage".
You can use any formula you want to get the value of "m". I put in an example for you.
CODE
/*FLAMES*/
#include<stdio.h>
#include<string.h>
// Needed for getch()
#include <conio.h>
int main()
{
char str1[20];
char str2[20];
int m;
// Collect first name
printf("Enter a name: \n");
gets(str1);
// Collect second name
printf("Enter another name: \n");
gets(str2);
// Compare to see if they are not equal
if(strcmp(str1,str2) != 0) {
// Here is one method you could use... add length of two names
// mod it with 6 to determine their relationship
// Store it into "m" (notice the casting to int and semicolon on the end)
m = (int)(strlen(str1) + strlen(str2)) % 6;
// Use "m" to print their relation
switch(m){
case 0:printf("Friends");break;
case 1:printf("Lovers");break;
case 2:printf("Anger");break;
case 3:printf("Marriage");break;
case 4:printf("Enemies");break;
case 5:printf("Sweethearts");break;
}
}
getch();
}
Read through the in code comments and you will see what I am doing. It is pretty straight forward. Hope this is what you were after.
Enjoy!
"At DIC we be making matches on a daily basis, we are match making code ninjas!"