There is not a basic style string handling library.
However BCX, the Basic to C translator is a great way to learn C and contains lots of examples. Write what you want to do in BCX and then run the translator and look at the C code generated.
I have adapted some BCX constructs for use in my C programs that handle lots of text.
Here are some examples:
/*
*
* FUNCTION: BCX_TmpStr
*
* PURPOSE: Provide temporary strings from a curcular storage array.
*
* PARAMS: size_t Bites - desired length of string
*
* RETURNS: LPSTR - pointer to the allocated temporary string
*
* History:
* March '07 - Borrowed from BCX
*
*/
LPSTR BCX_TmpStr (size_t Bites)
{
static int StrCnt;
static LPSTR StrFunc[2048];
StrCnt=(StrCnt + 1) & 2047;
if(StrFunc[StrCnt]) free (StrFunc[StrCnt]);
return StrFunc[StrCnt]=(char*)calloc(Bites+128,sizeof(char));
}
/*
*
* FUNCTION: Mid
*
* PURPOSE: Extract a substring from a given source string
* based on character start position in source string
* and an optional length.
*
* PARAMS: LPSTR lpSource - pointer to source string
* INT start - start position
* INT length - optional length of sub string
*
* RETURNS: LPSTR - extracted sub string
*
* History:
* March '07 - Borrowed from BCX
*
*/
LPSTR Mid (LPSTR, INT, INT=-1);
LPSTR Mid (LPSTR lpSource, INT start, INT length)
{
register int tmplen = strlen(lpSource);
LPSTR strtmp;
if(start>tmplen||start<1) return BCX_TmpStr(1);
if (length < 0) length = tmplen - start + 1;
strtmp = BCX_TmpStr(length);
return (LPSTR)memcpy(strtmp,&lpSource[start-1],length);
}
LPSTR Left (LPSTR mainStr, UINT length)
{
return Mid(mainStr,1,length);
}
LPSTR Right (LPSTR mainStr, UINT length)
{
return Mid(mainStr,strlen(mainStr)-length+1,-1);
}