Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String manipulation help.

Status
Not open for further replies.

golyg

Programmer
Jul 22, 2002
319
US
I have a string that is coming from a database that I want to break down into seperate parts, in order to view it on the screen, I've decided that they should be no larger than 55 characters. The max length of the initial string is 256 but could be as small as 10....
The string is dynamic.
So, If I have the string:
"This is a test string for my string manipulation help."

I would have this:(6 character max for this example):
string1: This i
string2: s a te
string3: st str
string4: ing fo
and so on .....


so far I have this, but I can't increment through the string..
Code:
csHint1	= m_stClosureMethodData.szMethodHint; //assign csHint1 to string in Db.
nStringLen = strlen(csHint1); 
nHintLines = (nStringLen / 55); 
nHintLines = nHintLines++; //to determine how many sets of 55 characters that I have, and add 1 for remainder
strncpy(string, csHint1, 55);
while (nHintLines > 0)
{				
   //AfxMessageBox(csHint);
   stHint.Add(string);	
   strncpy(string + 55, csHint1, 55);
   nHintLines = nHintLines--;
}
 
oh, here is the variable declarations:
Code:
CString csHint1, csHint2;
int nStringLen, nHintLines;
char string[257] = "";

thanks so much for the help.
 
When you are having a Class like CString, you can manipulate directly.... There are Left, Mid and Right to your aid...

strLeftFive = strOriginalString.Left(5)


Cheers,

Ravi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top