HighScore, getting the users name
I'm witing a highscore table for a game I'm making, and I've run in to a problem... Whenever I press a key the game quits... I get this error message: "First-chance exception in Game.exe: 0xC0000005: Access Violation." I have no idea what this means...
Code:
void HighScores()
{
bool bHSRunning = true;
bool bDown = true;
bool bChanged = false;
char strTemp[2];
char strName[50];
char strABC[30]("abcdefghijklmnopqrstuvwxyzåäö");
char str123[11]("0123456789");
int iKey = 0;
SetTextColor(g_hdc, RGB(255, 0, 0));
while(bHSRunning)
{
if(GetAsyncKeyState(VK_ESCAPE))
{
bHSRunning = false;
CleanUpHighScores();
g_iMenuState = 4;
}
for(int i = 0; i < 95; i++)
{
if(!bDown)
{
if(HIWORD(GetAsyncKeyState(i)))
{
if(i >= 48 && i <= 57)
{
strncpy(strTemp, str123 + (i - 48), 1);
bChanged = true;
iKey = i;
bDown = true;
i = 256;
}
if(i >= 65 && i <= 90)
{
strncpy(strTemp, strABC + (i - 65), 1);
bChanged = true;
iKey = i;
bDown = true;
i = 256;
}
if(i == 8) //8 == BackSpace
{
chardel(strName, strlen(strName));
TextOut(g_hdc, 100, 100, strName, strlen(strName));
iKey = i;
bDown = true;
i = 256;
}
}
}
if(bDown)
{
if(!HIWORD(GetAsyncKeyState(iKey)))
{
bDown = false;
}
}
}
if(GetAsyncKeyState(VK_SHIFT) || GetAsyncKeyState(VK_LSHIFT) || GetAsyncKeyState(VK_RSHIFT))
{
strupr(strTemp);
}
if(bChanged)
{
strcat(strName, strTemp);
TextOut(g_hdc, 100, 100, strName, strlen(strName));
bChanged = false;
}
}
}
It's a win32 app written in vc++6.0