-
>>you're saying that if you want an array of NULL pointers, you might as well just malloc it yourself and then have a loop to fill with NULLs?<<
Yes, that is the correct method.
>>is there any difference between
No, but the definition of calloc says that the first parameter represents the number of elements, so for style purposes your second version is better than the first.
-
While this NULL subject comes up, can we make a list of machines where NULL != all bits zero.
Has anyone on this board actually compiled one of their programs on one of these machines?
While we're are at it has anyone actually compiled a program on a machine where a char != 8 bits?
Thanks.
-
>>can we make a list
Personally, no I haven't used such a system. However, I've seen posts on here before giving specific details.
Whatever though, the Standard says things should be done this way, so that's the way you should be learning (speaking from a generic C perspective). Remember that in the case of a NULL pointer, the actual implementation is pretty much hidden from the programmer, so unless you go using indirect pointer access to see whats in memory, you might never know.
-
>While this NULL subject comes up, can we make a list of machines where NULL != all bits zero.
http://www.eskimo.com/~scs/C-faq/q5.17.html
>While we're are at it has anyone actually compiled a program on a machine where a char != 8 bits?
Yes.
-
>>While we're are at it has anyone actually compiled a program on a machine where a char != 8 bits?
>Yes.
Could you give details? Thanks.
-
>Could you give details? Thanks.
It's been a while. I believe it was for a TI DSP in the C54x family. CHAR_BIT was 16 and the sizeof char, short, and int were all 1.