Re: what is typecasting a pointer to the type (void *)p mean?
- From: Al Balmer <albalmer@xxxxxxx>
- Date: Wed, 25 Jan 2006 15:14:14 -0700
On Wed, 25 Jan 2006 23:07:54 +0100, Michael Rasmussen <mir@xxxxxxxxx>
wrote:
>On Wed, 25 Jan 2006 22:56:57 +0100, Emmanuel Delahaye wrote:
>
>>
>> Somehow, yes. Note that the conversion from/to void* doesn't need an
>> explicit typecast.
>>
>Well, not always but in this situation it is mandatory:
>void foo(void *t) {
> printf("%s", (char *) t);
>}
>
>int main() {
> char *t = "test";
> foo(t);
> return 0;
>}
>
>So might as well use explicit casting since it is a lot more readable for
>an outsider which later has to maintain the code. IMHO
void foo(void *t) {
char *rt = t;
printf("%s", rt);
}
--
Al Balmer
Sun City, AZ
.
- References:
- what is typecasting a pointer to the type (void *)p mean?
- From: Abhishek
- Re: what is typecasting a pointer to the type (void *)p mean?
- From: Michael Rasmussen
- Re: what is typecasting a pointer to the type (void *)p mean?
- From: Abhishek
- Re: what is typecasting a pointer to the type (void *)p mean?
- From: Emmanuel Delahaye
- Re: what is typecasting a pointer to the type (void *)p mean?
- From: Michael Rasmussen
- what is typecasting a pointer to the type (void *)p mean?
- Prev by Date: Re: what is typecasting a pointer to the type (void *)p mean?
- Next by Date: Re: what is typecasting a pointer to the type (void *)p mean?
- Previous by thread: Re: what is typecasting a pointer to the type (void *)p mean?
- Next by thread: Re: what is typecasting a pointer to the type (void *)p mean?
- Index(es):
Relevant Pages
|