Re: void * pointer convert problem.
- From: Christopher Benson-Manica <ataru@xxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 30 Dec 2005 18:12:34 +0000 (UTC)
Eric J.Hu <ehu@xxxxxxxxxx> wrote:
> vcnvt.c: In function `main':
> vcnvt.c:20: warning: dereferencing `void *' pointer
Pretty self-explanatory. You can't derefence void pointers. You can,
however, cast them back to their real type and then dereference them.
> int main()
> {
> void * vbPtr;
> counting_bin_t cBin[9];
> cBin[0].key = 9;
> vbPtr = cBin;
> printf("key is %d\n", vbPtr->key);
/* Like so */
printf( "key is %d\n", ((counting_bin_t*)vbPtr)->key );
> }
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
.
- Follow-Ups:
- Re: void * pointer convert problem.
- From: Eric J.Hu
- Re: void * pointer convert problem.
- References:
- void * pointer convert problem.
- From: Eric J.Hu
- void * pointer convert problem.
- Prev by Date: Re: Input-line reverser
- Next by Date: Re: gets() - dangerous?
- Previous by thread: void * pointer convert problem.
- Next by thread: Re: void * pointer convert problem.
- Index(es):