|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#include "sflstr.h"
char *
setstrfld (
char *strbuf,
int fldno,
int ofset,
char *sep,
char *strtoins)
Inserts a string into a fomated string. usage: char strsrray[26] = { "this is a test." }; setstrfld (strsrray, 2, 0, " ", "big "); result: this is a big test. Does nothing if fldno is out of range, else returns pointer to head of the buffer. Returns a pointer to head of the buffer. Submitted by Scott Beasley jscottb@infoave.com
{
char *offset, *strptr, *strhead;
int curfld;
ASSERT (strbuf);
ASSERT (sep);
ASSERT (strtoins);
offset = strptr = (char *)NULL;
curfld = 0;
strhead = strbuf;
strbuf += ofset;
while (*strbuf)
{
strptr = !offset ? strbuf : offset;
offset = strpbrk ((!offset ? strbuf : offset), sep);
if (offset)
offset++;
if (curfld == fldno)
{
insertstring (strptr, strtoins,
(int)(!offset ? strlen (strptr):
(int)(offset - strptr)));
break;
}
curfld++;
}
return strhead;
}
| | << | < | > | >> |
|