Search code examples
arraysctypedef

Does using typedef for an array take more memory than the array itself when allocated?


Simply, if I were to do:

typedef char arrayOne[10];

and in main:

char arrayTwo[10];

would malloc(sizeof(arrayOne)) take more memory than malloc(sizeof(arrayTwo)) ?

Or in other words; I'm using typedef to keep the code more simple, but is it worth it or I should just forget it because it uses unnecessary extra memory?


Solution

  • There's no relation between memory allocation & typedef. The keyword typedef simply creates aliases to make the long name datatypes into shorter & more meaningful to read.