Reputation: 47
I am having a difficult time getting why the answer is 66 bytes to the following question:
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
./program alfa beta gamma
Upvotes: 1
Views: 69
Reputation: 108968
The best I could come up with is
argv[0]
==> 8 bytes for pointer itself + 6 bytes for the data ("./app"
) ==> 14
argv[1]
==> 8 bytes for pointer itself + 5 bytes for the data ("alfa"
) ==> 13
argv[2]
==> 8 bytes for pointer itself + 5 bytes for the data ("beta"
) ==> 13
argv[3]
==> 8 bytes for pointer itself + 6 bytes for the data ("gamma"
) ==> 14
argv[4]
==> 8 bytes for the pointer (NULL
) ==> 8
TOTAL: 62
Maybe add 4 bytes for argc
for 66 bytes??
Upvotes: 2