Category : Files from Magazines
Archive   : CUJ9301.ZIP
Filename : 1101074A

 
Output of file : 1101074A contained in archive : CUJ9301.ZIP
/*****************************************************
File Name: STR_NGET.C
Description: Library of functions for geting
substrings in a string
Global Function List: str_nleft
str_nmid
str_nright
str_rstr
Portability: Standard C
******************************************************/

#include
#include
#include

/*****************************************************
Name: str_nleft
Expanded Name: Get Left N Characters
Parameters: Str - string to get left charaters
Num - number of characters to get
Return: Str
Description: Get Num leftmost charcters in Str.
Modifies Str.
*****************************************************/
char *str_nleft( char *Str, size_t Num )
{

if ( Num < strlen( Str ))
{
Str[Num] = '\0';
}

return ( Str );

} /* function str_nleft */


/*****************************************************
Name: str_nmid
Expanded Name: Get Middle N Characters
Parameters: Str - string to get substring in
Pos - index into Str of start of midstr
Num - count of charcters to get
Return: Str
Description: Get Num chars from middle of string.
*****************************************************/
char *str_nmid( char *Str, size_t Pos, size_t Num )
{

char *Mid;
size_t Len = strlen( Str );

if ( Pos >= Len )
{
/* Outside of string */
*Str = '\0';
return ( Str );
}

/* Adjust count if it extends outside of string */
if ( Pos + Num > Len )
{
Num = Len - Pos;
}

Mid = &Str[Pos];
memmove( (void *)Str, (void *)Mid, Num );
Str[Num] = '\0';

return ( Str );

} /* function str_nmid */


/*****************************************************
Name: str_nright
Expanded Name: Get Right N Characters
Parameters: Str - string to get right charaters
Num - number of characters to get
Return: Str
Description: Get Num righmost charcters in Str.
Modifies Str.
*****************************************************/
char *str_nright( char *Str, size_t Num )
{

size_t Len = strlen( Str );

return ( str_nmid( Str,
( Num > Len ? 0 : Len - Num ),
min( Num, Len ) ) );

} /* function str_nright */


/*****************************************************
Name: str_rstr
Expanded Name: String Right (Reverse) Search
Parameters: Str - string to search
Find - string to search for
Return: Pointer to last occurance of substring
Find in Str or NULL if not found
Description: Searches for last occurrence of sub
string Find within Str.
*****************************************************/
char *str_rstr( char *Str, char *Find )
{

char *StrResult = NULL, *StrWork = Str;

while ( ( StrWork =
strstr( StrWork, Find ) ) != NULL )
{
StrResult = StrWork;
StrWork++;
}

return ( StrResult );

} /* function str_rstr */

/* End of File */



  3 Responses to “Category : Files from Magazines
Archive   : CUJ9301.ZIP
Filename : 1101074A

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/