home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR9
/
TVTOOLS.ZIP
/
ACTLIB.ZIP
/
STRINGS.ZIP
/
RIGHT.C
< prev
next >
Wrap
Text File
|
1993-01-14
|
888b
|
36 lines
/* Copyright (C) 1993 Marc Stern (internet: stern@mble.philips.be) */
#include "strings.h"
/***
* Function : strright
*
* Description : Copy the last ... characters of a string.
*
* Decisions : If given length > string length : normal strcpy
* If given length <= 0 returns an empty string.
*
* Parameters : out char *out_str result
* in char *in_str in string
* in int length length to be copied
*
* Return code : pointer to result.
*
* OS/Compiler : All
*/
char *strright( char *out_str, const char *in_str, int length )
{ const char *ptr = in_str;
if ( length <= 0 ) { *out_str = '\0';
return out_str;
}
while ( *ptr++ );
if ( ptr - length - 1 > in_str ) in_str = ptr - length - 1;
return strcpy( out_str, in_str );
}