Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Questions about sizeof and malloc
Questions about sizeof and malloc
1.malloc needs a positive integer as a parameter, which can be calculated by sizeof, but unlike new int[], malloc returns void*, new int[n] applies for 4*n bytes and returns int*.

2.(int *)malloc( 100) actually means 100 bytes of memory.

3.sizeof(3) is equal to 4 because 3 is an int type and has nothing to do with the specific value.