Dj_Fx8
asked on
Fill a String
Hi
Is there a way to fill a string with say 6 spaces ie
CString str= Fill(6, " ")
or do I have to write it myself
Is there a way to fill a string with say 6 spaces ie
CString str= Fill(6, " ")
or do I have to write it myself
Or
void Fill (CString& str, char cFill, int nCount)
{
char* cs = str.GetBufferSetLength (nCount);
memset (cs, cFill, nCount);
str.ReleaseBuffer (nCount);
}
void Fill (CString& str, char cFill, int nCount)
{
char* cs = str.GetBufferSetLength (nCount);
memset (cs, cFill, nCount);
str.ReleaseBuffer (nCount);
}
CString s(" "); //s contains 6 spaces
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
Thanks for all your replies, I'm will award the points to Jaime as his answer is a simple one line of code and best answers my question
Thanks for all your replies, I'm will award the points to Jaime as his answer is a simple one line of code and best answers my question
Those points are walking too slow. ;-P
Thanks anyway!
Thanks anyway!
char* cs = new char[7];
memset (cs, ' ', 7);
*cs[6] = '0x0';
CString str = cs;
delete [] cs;