| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

setstrfld

#include "sflstr.h"
char *
setstrfld (
    char *strbuf,
    int fldno,
    int ofset,
    char *sep,
    char *strtoins)

Synopsis

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

Source Code - (sflstr.c)

{
   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;
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation