On Thu, Jan 27, 2005 at 12:02:58PM +0800, Ron Michael Khu wrote: > extra typing?? r u using the term "type" in the same context as "data > type"(progamming language concept)? > or "type" in the sense "keyboard typing"??
The latter. Jeff was telling me that I had to cast all of the arguments to (void *), rather than, as you correctly said, the return value. It doesn't seem to me (or more importantly, to the compiler) that casting the ARGUMENTS is necessary? > > *TAKE NOTE of the enclosing parenthesis: > ((char*)SOMETHING)[index] ='\0' I did get it right later in my post, didn't I? > >Or, I guess, to follow Ron's suggestion too: > > > > ((char*) memcpy ((void *) *data_buf, (void *) bp, len)) [len] = '\0'; > > P.S. Hmmmm... u seem to have trouble understanding what a "void*" is. > Void * could be anything.. thus u cant simply go around indexing a void* > and treating it like an array without properly casting it... I'm starting to grok it. I learned C back in the old days before there was such a thing, and you could pretty much do anything you wanted with any pointer. Could sure shoot yourself in the foot if you weren't paying attention! Actually, I suppose back then memcpy and the like returned char*. To test my understanding: I have to cast the function because of the indexing operation. If I just ASSIGN the return value, then the compiler does implicit type-casting for me. As in: char *bp; bp = memcpy(foo,bar,len); Thanks for your help; I actually managed to get the program to compile with no errors, but now am getting a segmentation fault which I can't track down, so I'll probably be back to plague you folks some more! Scott. - 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
