Is it necessary to multiply by sizeof( char ) when manipulating memory?

后端 未结 8 1101
走了就别回头了
走了就别回头了 2021-01-01 22:26

When using malloc and doing similar memory manipulation can I rely on sizeof( char ) being always 1?

For example I need to allocate memory for N elements of type

8条回答
  •  孤城傲影
    2021-01-01 22:37

    sizeof(char) is always 1 no matter what type of memory manipulation you do.

    However, sizeof(TCHAR) may vary depending upon your compiler options.

提交回复
热议问题