Chris said:
You are most certainly welcome.
It's irrelevant to the answer, and normally size_t is an int anyway. I
could have said it's a size_t, but it might have created more problems
than it solved for the question-asker.
Um first off, no "size_t" isn't int. I'd think if anything it would be
"unsigned" not just an int. Anyways the type is size_t. Why bother
replying with "seemingly useful facts" if you're just going to mess with
them?
Um, yes you do, if you want truly portable code.
No, no you don't. The C standards [C90, C99] don't require you to cast a
void pointer to any other pointer type. If you're code is supposed to work
in C++ as well then maybe. However, putting the cast in can mask a more
serious problem that you forget to include stdlib.h.
Alright... Do you want to write one up for our embedded system? There
have two compilers, one based on GCC, and neither of them like it if you
equate two pointer types to each other without casting.
Um dude I've coded for embedded platforms before [from 8085, AVR, 68xx
series to the ARM based boards] and in all cases I've never casted a void
pointer to something.
In particular for the ARM boards you can use GCC and it will accept the
non-cast code just fine.
Me thinks you might want to preface your responses with "I used casts cuz my
non-standard compiler asked me to". This is afterall comp.lang.c and we're
not talking about "vendor lang c"
This isn't dynamic though [hint: read the OPs question] it's always
20x20
This is true, but I got the impression that he had no idea how to use
malloc. I was trying to solve his confusion relating to malloc itself.
Point him to the manual pages. Why bother answering his question with code?
How the hell do you think all these "coders" get out there? They take an
ounce of knowledge and spread it so thin to get a job....
If the dude can't learn from a manual page [or googling on the net] then too
F'ing bad.
Tom