I am trying to convert a CString to an int for use in a for loop, this should be simple, but I am new to Visual C++ and only a novice programmer, any help would be greatly appreciated.
This function is looking at a string of compressed data similar to this ( 1345!451345) the important information in the string is the !45 which means ! = flag 4 is the number and 5 is the multiplyer, after it is decompressed it would look like this 44444, total string 1345444441345.
Hope this is enough info.
// The expanding algorithm that will expand the data
CString CRLEView::expand(CString line)
{
int length = line.GetLength();
int i;
int j;
int times;
CString reada;
CString final;
char multiplyer;
for (i=0; i < length; i++)
{//reading characters one at a time
reada = line[i];
if (reada = "!") //Encounters the flag
{
i++;
reada = line[i];
//loop number of times the multiplyer requires outputing the character
i++;
multiplyer = line[i];
times = static_cast<int>(multiplyer);
for(j=1;j < times;j++)
{
final = final+reada;
}
}
else
{//No flag means to just output the actual character.
final = final + reada;
}
}
return CString();
other wise u'll see weird results
for 32 bit integers MAXINT is
4294967295 .. which is much less than ur example of
1345444441345