I'm not having any problems with either getchar( )s, although I did get rid of town( ), and made playermaxlife=50, playermaxmana=5, ... ints. That should not have affected anything.
For the second question I made an enum and a very stripped down class for getting you started. That is of course if I understood the question.
Code:
#include "stdafx.h"
#include <cstring>
#include <iostream>
using std::string;
using std::cout;
using std::endl;
enum WeaponType
{
shortsword,
longsword,
mondosward
};
class CWeaponName
{
protected:
WeaponType m_wt;
string m_sWeaponName;
public:
CWeaponName( ) : m_wt(shortsword), m_sWeaponName( "" )
{}
const char * getweapon( )
{
return m_sWeaponName.data( );
}
void setweapon( WeaponType wt )
{
switch( wt )
{
case shortsword:
m_wt = shortsword;
m_sWeaponName = "shortsword";
break;
case longsword:
m_wt = longsword;
m_sWeaponName = "mondosward";
break;
case mondosward:
m_wt = mondosward;
m_sWeaponName = "mondosward";
break;
}
}
};
int main(int argc, char* argv[])
{
CWeaponName wp;
wp.setweapon( shortsword );
cout << wp.getweapon( ) << endl;
wp.setweapon( longsword );
cout << wp.getweapon( ) << endl;
wp.setweapon( mondosward );
cout << wp.getweapon( ) << endl;
return 0;
}
I hope this is what your looking for.
dang