X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Message-ID: <464B3526.2080909@schluessler.org> Date: Wed, 16 May 2007 18:45:26 +0200 From: =?ISO-8859-1?Q?Timo_Schl=FC=DFler?= User-Agent: Thunderbird 1.5.0.7 (X11/20061202) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: How to count the occurance of a character in a string? References: <20070511181210 DOT GT3209 AT freenet DOT de> <20070512111553 DOT GO1881 AT freenet DOT de> <20070515164057 DOT GC1818 AT freenet DOT de> <20070516160358 DOT GA20179 AT freenet DOT de> In-Reply-To: <20070516160358.GA20179@freenet.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-RZG-AUTH: lrVxSROSz8bd/08MH76VyqIxu4p9LgPLNDGEyLDcC+eGuhga3Dy2UTeqREeGyj/OHx9+sjU= X-RZG-CLASS-ID: mo07 Reply-To: djgpp AT delorie DOT com Michelle Konzack wrote: > Hello Cesar, > > Am 2007-05-16 12:16:57, schrieb Cesar Rabak: >> OK Michelle, >> >> I think I'm _almost_ understood what you need (or perhaps not ;-) let's see: >> >> It seems obvious at this time that just counting the number of dots in >> the strings is not what you need/want, as this is trivial in C. >> >> So would you like to build a function in C that receiving as argument a >> string like: >> >> ~/INBOX/ returns ~/INBOX/ >> /INBOX.ML_devel/ returns .ML_devel/ >> /INBOX.ML_devel.djgpp/ returns .djgpp/ >> >> Is it there near of your needs? > > Nearly right, but I need the depth of it (e.g.: .djgpp = 2) and the name. > > If I use "#define _GNU_SOURCE" I can use under Linux glibc strdupa() > and strtok(). > > But since strdupa() does not exist under DJGPP, I have some problems > > > Thanks, Greetings and nice Day > Michelle Konzack > > Do you only need strdup() or strdupa() ?? Why don't you write your own? Like: char *strdup(const char *s) { size_t len = strlen (s) + 1; char *result = (char*) malloc (len); if (result == (char*) 0) return (char*) 0; return (char*) memcpy (result, s, len); } (This is the code for the real strdup() function.) All the best and sorry for writting if this wasn't your real problem