Okay, what happened to my literal strings?
Janice Caron
caron800 at googlemail.com
Mon Sep 10 06:37:12 PDT 2007
OK, I figured it out. Here's how you do it in C.
#define strchr(p,c) (p + istrchr(p,c))
int istrchr(const char * p, char c)
{
int i;
for (i=0; p[i]; ++i)
{
if (p[i] == c) return i;
}
return (const char *)0 - p;
}
As required, the parameter is const at the callee site, but the output is
the same type as the input at the caller site.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20070910/259a3905/attachment.html>
More information about the Digitalmars-d
mailing list