I was just trying to get it to run through once. It looks like this now:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include "game.h"
#define TEMPLATE "______"
int main ()
{
char words[][10]={"strong","quaint","garage","apples","budget","answer","matter","dollar","pursue","please"};
char myword[7];
char nexttime[] = "Maybe next time!";
char template[7];
char guess[7];
char used[] = " ";
char letter, yn;
int i, j, k, play, finish;
srand(time(NULL));
play = menu();
while( play == 1)
{
switch(play)
{
case 1:
strcpy(template,TEMPLATE);
strcpy(used," ");
system("cls");
i=1+(rand()%9);
strcpy(myword, words[i]);
printf("\n");
printf(template);
printf("\n");
printf("\n");
printf("\n");
finish = 0;
for(j=0; j<=7 && !finish; j++)
{
printf("\nPlease enter a letter: ");
scanf("%s", &letter);
used[j]=letter;
system("cls");
for(k=0; k<=5 && !finish; k++)
{
if(myword[k] == letter)
template[k]=letter;
if(strcmp(myword, template)==0)
{
printf("\nCorrect, the word was %s.\n", myword);
printf("\n");
finish = 1;
}
}
printf("\n");
printf(template);
printf("\n");
printf("\n");
printf("Letters guessed: %s", used);
printf("\n");
if (!finish)
{
printf("\nWould you like to guess the 6 letter word? y or n: ");
scanf("%s", &yn);
switch(yn)
{
case 'y':
printf("Word:");
scanf("%s", guess);
if(strcmp(myword, guess)==0)
{
printf("\nCorrect, the word was %s.\n", myword);
printf("\n");
finish = 1;
}
else
{
printf("\nWrong!\n ");
}
break;
case 'n':
system("cls");
printf("\n");
printf(template);
printf("\n");
printf("\n");
printf("Letters guessed: %s", used);
printf("\n");
break;
}
}
}
if (!finish)
{
printf("\nYou lost! \n");
}
break;
case 2:
printf("%s\n", nexttime);
break;
default:
printf("\nYou must choose option 1 or option 2!\n");
printf("\n");
}
play = menu();
}
return 0;
}
p.s.
red_baron, I found your games page and I have to tell you, my boyfriend loved your Moria game. He played with it for like an hour and a half last night.