[Coco] "C string searching question

Bill Pierce ooogalapasooo at aol.com
Mon Oct 1 23:15:06 EDT 2012


Here's a "C" programming question for you "C" gurus out there

I'm writing a search routine for SoundChaser's 500 song database.
here's the data format:

#define NRECORDS 500   /* max num of records */
#define RECNAMEL  33    /* size of record name */

typedef struct{
   char recname[RECNAMEL];   /* song name */
   char ext[4];    /* filename extension */
   int typ;     /* song type (midi mus ect ) */
   int order;   /* selection order */
   bool played   /* has played flag */
} Record;


direct short nrecords;  /* actual number of records */
Record records[ ];   /* the record keeper */
char srchstr[10];  /* the search string

ok, here's the loop:

loop to input srchstr[xx] here

for(cnt=0; cnt<=nrecords; cnt++) {
   for(xx=0; xx<=sizeof(srchstr); xx++){
      if(srchstr[xx] == records[cnt].recname[xx]) {
          search some stuff here..
          then search some more stuff
      }
   }
}

what should I do in the loop or is there a better looping routine I can use to find the matching string.
The record will be searched for the matching sting anywhere in the record i.e.   search for rock;  likearock; rocknroll; iluvrocknroll;
what would be the best way to do this efficiantly?
the result has to point to cnt as that will be the index to the record found.

any ideas? (I just love cans of worms)
Bill P
Music from the Tandy/Radio Shack Color Computer 2 & 3

https://sites.google.com/site/dabarnstudio/
Bill Pierce
ooogalapasooo at aol.com




More information about the Coco mailing list