Pages

Monday, July 15, 2024

Find the output - size of pointers

 

#include <stdio.h>
#include <string.h>

int main()
{
    void *str = "Hello";
    printf("%1d %1d\n ",strlen(str),sizeof(str));
    return 0;
}


Output

5,8


Explanation

strlen returns the size of the string i.e. "Hello" takes 5bytes

sizeof gives the size allocated for the datatype, In our case a pointer is allocated 8bytes

No comments:

Post a Comment

What is anti- Debugging

  Anti- debugging is how we can stop somebody from debugging our system and getting all the information out of your subsystem.