[Coco] "C string searching question

Bill Pierce ooogalapasooo at aol.com
Tue Oct 2 00:01:38 EDT 2012


<I don't suppose you have access to library functions like strlen() and
<strchr() and strstr() in that context, do you?

Yes, they are supported. I have all the "C" libraries I could find for OS9 "C"
I'm relatively "new" to "C" so this why I'm asking. I need a method of searching that is quick and easy and "C"s string routines are something I haven't delved into yet. I'm used to basic's MID$ and such and not familiar with Cs string manipulating methods. I've been doing some reading in the manuals, but the manuals seem to be a bit cryptic to say the least. The K&R manual is a little better but a lot isn't supported by MW's Coco OS9 C.

Bill P

Music from the Tandy/Radio Shack Color Computer 2 & 3
https://sites.google.com/site/dabarnstudio/
Bill Pierce
ooogalapasooo at aol.com




-----Original Message-----
From: Juan Castro <jccyc1965 at gmail.com>
To: CoCoList for Color Computer Enthusiasts <coco at maltedmedia.com>
Sent: Mon, Oct 1, 2012 11:51 pm
Subject: Re: [Coco] "C string searching question



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

--
Coco mailing list
Coco at maltedmedia.com
http://five.pairlist.net/mailman/listinfo/coco

 



More information about the Coco mailing list