[Coco] "C string searching question
Juan Castro
jccyc1965 at gmail.com
Mon Oct 1 23:50:34 EDT 2012
I don't suppose you have access to library functions like strlen() and
strchr() and strstr() in that context, do you?
On Tue, Oct 2, 2012 at 12:15 AM, Bill Pierce <ooogalapasooo at aol.com> wrote:
>
> 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
>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> http://five.pairlist.net/mailman/listinfo/coco
More information about the Coco
mailing list