WHY WON'T IT WORK?!?!?!

Code:
#include <iostream>
#include <cstdlib>
#include <string>
#include <ctime>
#include <type.h>
using namespace std;
const int NUM = 2;
const string wordlist[NUM] = {"apiary", "cereal};
int main()
{
srand(time(0));
char play;
char gen;
cout << "Are you a sir or mam?\n";
cin gen;
cout << "Okay, ";
cout << gen;
cout << "Play my wordgame? <y/n> ";
cin play;
play = tolower(play);
while (play == 'y')
{
string target = wordlist[rand() % NUM];
int length = target.length();
string attempt(length, '-');
string badchars;
int guesse = 6;
cout << "Guess my secret word. It has " << length
     << " letters, and you guess\n";
     << "one letter at a time. You get " << guesses
     << " wrong guesses.\n";
cout << "Yor word: " << attempt << endl;
while (guesses > 0 && attempt != target)
{
char letter
cout << "Guess a letter: ";
cin letter;
if (badchars.find(letter) != string::npos
    || attempt.find(letter) != string::npos)
    {
    cout << "You already guessed that!\n";
         continue;
    }
    int loc = target.find(letter);
    if (loc == string::npos)
    {
    cout << "Oh! Bad luck, and guess!\n";
    --guesses;
    badchars += letter;
    }
    else
    {
    cout << "Good choice, ";
    cout << gen;
    attempt[loc]=letter;
    loc = target.find(letter, loc + 1);
    while (loc != string::npos)
    {
     attempt[loc=letter;
     loc = target.find(letter, loc + 1);
    }
}
cout << "Your word: " << attempt << endl;
if (attempt != target)
{
if (badchars.length() > 0)
   cout << "Bad chaoices: " << badchars << endl;
 cout << guesses << " bad guesses left.\n";
}
}
if (guesses > 0)
    cout << "Correct!\n";
else
    cout << "Nope! The word is: " << target << ".\n";

cout << "Will you play another?: ";
cin >> play;
play = tolower(play);
}



cout << "Bye!\n";

system ("PAUSE");
return 0;
}
AAARGH!