|
-
April 26th, 2004, 10:13 PM
#21
A humbling experience...
Hi gurus:
The code snipped, along with the "std::string Mystring" worked like a charm... amazing. Just for you guys to get a good laugh, this is what I have to do to get those darn 10 bytes off the string:
// -----------------------------------------------------------------------------------------
// RightS: Copies the rightmost NumChars characters from the string_in to string_out
// -----------------------------------------------------------------------------------------
void RightS(char*string_in,int NumChars, char*string_out)
{
char temp[80];
int length = strlen(string_in);
int i, start, ctr;
start = length - NumChars;
for (i = 0; i <= NumChars; i = i + 1)
{
ctr = start + i;
temp[i] = string_in[ctr];
}
temp[NumChars+1] = '\0';
strcpy(string_out,temp);
}
You can laugh, no problem. I know it´s bizarre, but.. you know, desperation is the mother of creativity, I guess.
But that little code snipped took it of it elegantly. And yes, it was <string>. the <string.h> it´s for something else... I write off as a good experience.
Thanks again,
Luis
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|