🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #5762

Re: string

#5762
From: Serve Laurijssen
Date: Sun, 09 Mar 2003 16:34
24 lines
2071 bytes
"Serve Laurijssen" <oh@ja.nl> wrote in message
news:b4fq8d$39$1@news2.tilbu1.nb.home.nl...
>
> "Dominique Devriese" <dominique.devriese@student.kuleuven.ac.be> wrote in
> message news:87d6l0zfb4.fsf@appel.kotnet.org...
> > Ivan Van den Bossche writes:
> >
> >   Ivan> Hi, Kan er mij iemand vertellen welke functie ik in C moet
> >   Ivan> gebruiken om:
> >
> >   Ivan> een waarde terug te krijgen van de index van de eerste
> >   Ivan> karakter in een bepaalde substring die voorkomt in een gegeven
> >   Ivan> string?  In Delphi bestaat er een Pos functie.  Welke is deze
> >   Ivan> in de programmeertaal C?
> >
> > strchr
>
> bijna, die stuurt een pointer terug en zoekt naar een letter.
> char *p = strstr(s, "bleat");
> size_t pos = p ? p - s : -1;

en oh, wat een bug! doe maar
int pos = p ? p - s : -1;
Technical Details
Message-ID: <b4fqe5$1pl$1@news2.tilbu1.nb.home.nl>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!hermes.visi.com!news.maxwell.syr.edu!skynet.be!skynet.be!213.51.129.3.MISMATCH!newshub1.home.nl!home.nl!not-for-mail
References: <_LJaa.3647$Vq.390@afrodite.telenet-ops.be> <87d6l0zfb4.fsf@appel.kotnet.org> <b4fq8d$39$1@news2.tilbu1.nb.home.nl>

Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit
X-Google-Thread: 107324,37a026138681813
X-Google-Attributes: gid107324,public
X-Google-Thread: fcea4,37a026138681813
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2003-03-09 08:34:20 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!hermes.visi.com!news.maxwell.syr.edu!skynet.be!skynet.be!213.51.129.3.MISMATCH!newshub1.home.nl!home.nl!not-for-mail
From: "Serve Laurijssen" <oh@ja.nl>
Newsgroups: be.comp.programming,nl.comp.programmeren
Subject: Re: string
Date: Sun, 9 Mar 2003 17:34:19 +0100
Organization: @Home Benelux
Lines: 26
Message-ID: <b4fqe5$1pl$1@news2.tilbu1.nb.home.nl>
References: <_LJaa.3647$Vq.390@afrodite.telenet-ops.be> <87d6l0zfb4.fsf@appel.kotnet.org> <b4fq8d$39$1@news2.tilbu1.nb.home.nl>
NNTP-Posting-Host: cp179079-a.tilbu1.nb.home.nl
X-Trace: news2.tilbu1.nb.home.nl 1047227653 1845 217.120.117.137 (9 Mar 2003 16:34:13 GMT)
X-Complaints-To: abuse@home.nl
NNTP-Posting-Date: Sun, 9 Mar 2003 16:34:13 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106