I'm trying to parse a char array and based on each individual letter value set an int value in a corresponding int array (it's for a bitmap font class in DirectX). Anyway here's what I've tried and where I'm stuck:
Code:
char *cTextIn, cCurLetter;
strcpy(cTextIn,"ThisIsATest");
int iLen=strlen(cTextIn);
for(int i=0;i<iLen;i++)
{
cCurLetter=*cTextIn++;
cout<<cCurLetter;
}
This works fine to give me the current letter incrimentally, but when I try to test that letter with strcmp I get an error during compile because it can't use a char where it needs a const char*.
Code:
int iPlaceInAlphabet;
if(strcmp(cCurLetter,"a")==0) iPlaceInAlphabet=0;
if(strcmp(cCurLetter,"b")==0) iPlaceInAlphabet=1;
//etc. etc.
To correct this I've tried using casting it which compiles fine but then I get an unhandled exception at runtime.
Code:
int iPlaceInAlphabet;
if(strcmp((const char*)cCurLetter,"a")==0) iPlaceInAlphabet=0;
if(strcmp((const char*)cCurLetter,"b")==0) iPlaceInAlphabet=1;
//etc. etc.
Does anyone else have experience with this?
What I have is a bitmap with the letters of the alphabet in a row, each letter is 32x32 pixels. Based on each letter parsed it will set an int value in a corresponding int array. The values in this int array are used to determine the source RECTs for the letter's to be blitted.
Thanks in advance for any help.