Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char *StripCarriageReturns ( const char *thestring )
- {
- UplinkAssert (thestring);
- // Is there a cr?
- char *firstcr = strchr ( thestring, '\n' );
- if ( !firstcr ) {
- // No cr found - copy string and return it
- char *result = new char [strlen(thestring)+1];
- strcpy ( result, thestring );
- return result;
- }
- else {
- // Found a cr - so shorten string to that point
- int newlength = firstcr - thestring;
- char *result = new char [newlength+1];
- strncpy ( result, thestring, newlength );
- result [newlength] = '\x0';
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement