[英]Question regarding memory allocation in C
I am having a difficult time getting why the answer is 66 bytes to the following question:我很难理解为什么以下问题的答案是 66 字节:
How much memory gets allocated for the data passed through the pointer in the main functions 2nd parameter(not considering the pointer size) in a 64 bit system, if the app is run with在 64 位系统中,如果应用程序运行在
./program alfa beta gamma
The best I could come up with is我能想到的最好的方法是
argv[0]
==> 8 bytes for pointer itself + 6 bytes for the data ( "./app"
) ==> 14 argv[0]
==> 8 个字节用于指针本身 + 6 个字节用于数据( "./app"
)==> 14
argv[1]
==> 8 bytes for pointer itself + 5 bytes for the data ( "alfa"
) ==> 13 argv[1]
==> 8 个字节用于指针本身 + 5 个字节用于数据( "alfa"
)==> 13
argv[2]
==> 8 bytes for pointer itself + 5 bytes for the data ( "beta"
) ==> 13 argv[2]
==> 8 个字节用于指针本身 + 5 个字节用于数据( "beta"
)==> 13
argv[3]
==> 8 bytes for pointer itself + 6 bytes for the data ( "gamma"
) ==> 14 argv[3]
==> 8 个字节用于指针本身 + 6 个字节用于数据( "gamma"
)==> 14
argv[4]
==> 8 bytes for the pointer ( NULL
) ==> 8 argv[4]
==> 8 个字节的指针( NULL
)==> 8
TOTAL: 62总计:62
Maybe add 4 bytes for argc
for 66 bytes??也许为
argc
添加 4 个字节以获得66个字节?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.