Skip to contentSkip to conversation

Into the Void

DISCUSSION Scott 2 participants 2 messages Jan 26, 2005

lore
Share & tools
lore

Scott

author
#0 lore raw

Years ago, I learned this trick from somebody in the C/C++ Journal, or whatever that rag was called:

           memcpy(*data_buf,bp,len)[len] = '\0';

I get the following error:

indatax.c: In function `read_datum':
indatax.c:374: warning: dereferencing `void *' pointer indatax.c:374: invalid use of void expression

and if I cast the function:

           (char *) memcpy(*data_buf,bp,len)[len] = '\0';

I get:

indatax.c: In function `read_datum':
indatax.c:374: warning: dereferencing `void *' pointer indatax.c:374: void value not ignored as it ought to be

What aren't I understanding here? Tell me to go away if these questions are too elementary for the list....

#1 lore raw

why dont u try casting the whole thing?? (putting an enclosing parenthesis on ur memcpy oper)

((char *) memcpy(*data_buf,bp,len))[len] = '\0';

Quoted 31 lines · Scott

Years ago, I learned this trick from somebody in the C/C++ Journal, or whatever that rag was called:

          memcpy(*data_buf,bp,len)[len] = '\0';

I get the following error:

indatax.c: In function `read_datum':
indatax.c:374: warning: dereferencing `void *' pointer indatax.c:374: invalid use of void expression

and if I cast the function:

          (char *) memcpy(*data_buf,bp,len)[len] = '\0';

I get:

indatax.c: In function `read_datum':
indatax.c:374: warning: dereferencing `void *' pointer indatax.c:374: void value not ignored as it ought to be

What aren't I understanding here? Tell me to go away if these questions are too elementary for the list....
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html