Re: Program crashes when running it outside dev environment
- From: pete <pfiland@xxxxxxxxxxxxxx>
- Date: Fri, 08 Jun 2007 23:05:38 GMT
Harald van =?UTF-8?B?RMSzaw==?= wrote:
Richard Heathfield wrote:
But I don't know
of any occasion where you *need* a cast AND omitting it violates a
constraint or constitutes a syntax error.
I can't think of a concrete example of a cast which
causes a constraint
violation or syntax error when left out either, but diagnostics are
permitted for other code as well.
You need a cast if you're writing a function like strchr, strstr
or bsearch, which returns a pointer to an unqualified type,
which is derived from a parameter that points to a qualified type.
char *strstr(const char *s1, const char *s2)
{
const int c = *s2++;
if (c != '\0') {
const size_t n = strlen(s2);
s1 = strchr(s1, c);
while (s1 != NULL && strncmp(s1 + 1, s2, n) != 0) {
s1 = strchr(s1 + 1, c);
}
}
return (char *)s1;
}
--
pete
.
- Follow-Ups:
- Re: Program crashes when running it outside dev environment
- From: Keith Thompson
- Re: Program crashes when running it outside dev environment
- From: Richard Heathfield
- Re: Program crashes when running it outside dev environment
- References:
- Program crashes when running it outside dev environment
- From: z
- Re: Program crashes when running it outside dev environment
- From: Richard Heathfield
- Re: Program crashes when running it outside dev environment
- From: David Tiktin
- Re: Program crashes when running it outside dev environment
- From: Richard Heathfield
- Re: Program crashes when running it outside dev environment
- From: Harald van Dijk
- Program crashes when running it outside dev environment
- Prev by Date: Re: malloc without stdlib.h
- Next by Date: Re: Program crashes when running it outside dev environment
- Previous by thread: Re: Program crashes when running it outside dev environment
- Next by thread: Re: Program crashes when running it outside dev environment
- Index(es):
Relevant Pages
|