X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Message-ID: <464E15EA.DC2A59E2@yahoo.com> Date: Fri, 18 May 2007 17:08:58 -0400 From: CBFalconer Organization: Ched Research http://cbfalconer.home.att.net X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp 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> <464B3526 DOT 2080909 AT schluessler DOT org> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Lines: 27 NNTP-Posting-Date: 18 May 2007 20:35:19 GMT X-Complaints-To: abuse AT teranews DOT com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Timo Schlüßler wrote: > ... snip ... > > 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.) I hope not. Every one of those casts is unnecessary, and only serves to conceal errors, such as failure to #include . Besides which, there is no strdup routine in standard C. POSIX and Linux may be different. It is available under DJGPP. -- cbfalconer at maineline dot net -- Posted via a free Usenet account from http://www.teranews.com