In main, sizeof(buf) is 500, but in the function, sizeof(buf) comes out as 4. Can you tell me the reason?c
The buf in main is
char buf. At this point, size of (buf) is 500.
The buf in the function represents
char buf, which is a pointer variable that receives only the address value of the buf in the main. The pointer variable is usually 4 bytes in size, so the size of (buf) in the function is 4.
It is common to modify the function form as shown below and run
Load(buf, sizeof(buf) in the main function to use the size value inside the function.
© 2022 pinfo. All rights reserved.