troubleshooting Question

Converting a CString to an int

Avatar of Alias_
Alias_ asked on
C++
5 Comments1 Solution834 ViewsLast Modified:
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();
ASKER CERTIFIED SOLUTION
curmudgeon42

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros