www.pudn.com > CRGAB.zip > CBSTRGS.C


/* 
HEADER:		; 
TITLE:		BASIC-like string functions; 
VERSION:	1.0; 
 
DESCRIPTION:    Functions in C to implement the BASIC string functions MID$ 
		and RIGHT$; 
 
KEYWORDS:	String utilities; 
SYSTEM:		MSDOS; 
FILENAME:	CBstrgs; 
WARNINGS:	None; 
SEE ALSO:	Wgets; 
 
AUTHORS:	Dr. Ronald J. Terry; 
COMPILERS:	Turbo C; 
*/ 
#include  
#include  
 
/*************************************************************************** 
 *                             Function: Mid                               * 
 *          Mid selects 'nofchar' characters beginning at 'start'          * 
 ***************************************************************************/ 
 
char *Mid(char *str, int start, int nofchar) 
{ 
     int strgleng = strlen(str), stop; 
     char *newstr, *newstr2; 
     newstr = calloc(strgleng+1,sizeof(char)); 
     newstr2 = newstr; 
     if(start<1 || nofchar<1 || start>strgleng) 
       return(newstr=NULL); 
     --start; 
     if((nofchar+start)>strgleng) 
       nofchar = strgleng - start; 
     stop = start + nofchar; 
     while(start