Re: Refreshed genx.h, plus some plans

From
Daniel James <>
To
Date
2004-01-25T16:01:36Z
ID
<>
Thread
Re: Refreshed genx.h, plus some plans
On Sat, 24 Jan 2004 23:23:06 -0800, Jeremy H. Griffith wrote:

> Gee, you'd better tell Microsoft!  Their entire C Library for Visual C
> uses const throughout.  <bg>  A few simple examples:
> 
> size_t strlen( const char *string );
> int strcmp( const char *string1, const char *string2 );
> size_t strspn( const char *string1, const char *string2 );
> char *strrchr( const char *string, int c );

The const in strrchr (and strchar, strstr, strpbrk etc.) isn't too great:

#include <stdio.h>

int main()
{
    const char text[] = "Foo";
    *strrchr(text, 'F') = 'B';
    puts(text);
}

Although that doesn't stop const being useful, just points out a
problem with the C standard library.

Daniel