Originally Posted by
tabstop
2. No C compilers require that you perform typecasting in this situation -- and in fact doing so is more likely wrong than right in C (since it is used to cover a lack of #include files). However, all
C++ compilers do require it.
3. Sort of. sizeof(char) is guaranteed to be 1 and therefore this is rather useless. But in general, you will often see things like:
Code:
name = malloc(80 * sizeof(*name));
where instead of using the typename you specify "80 of the things name points to" -- so if this changes, this line will track that change.
3. Why we're not performing typecasting in this situation, as?
Code:
name = (int *) malloc(80 * sizeof(*name));