Q:

Segmentation Fault in typecasting from unsigned int to char pointer

I'm new to c. Just learning.
What i am trying to do is initialize a variable type of unsigned int and then store address of an char type array in it and after that I am trying to use int as a pointer and print the array using the unsigned int but I'am getting segmentation fault, I don't know why? 
It's printing value of memory address of char type array. But not the actual values at memory addresses.
Can someone please help?
#include <stdio.h>

int main()
{
    char char_arr[4] = {'a', 'b', 'c', 'd'};
    int i;

    unsigned int hackyPointer;
    hackyPointer = (unsigned int) char_arr;

        for (i = 0; i < 4; i++)
        {
            printf("[hacky Pointer] now points to %p which contains value %c\n",hackyPointer, *((char *) hackyPointer));
            hackyPointer += sizeof(char);
        }

}

A:

What you are trying to do is the following
#include <stdio.h>
#include <stdint.h>

int main()
{
    char char_arr[4] = {'a', 'b', 'c', 'd'};
    int i;

    uintptr_t hackyPointer;
    hackyPointer = (uintptr_t) char_arr;

        for (i = 0; i < 4; i++)
        {
            printf("[hacky Pointer] now points to %p which contains value %c\n",( void * )hackyPointer, *((char *) hackyPointer));
            hackyPointer += sizeof(char);
        }
}        

The program output is
[hacky Pointer] now points to 0x7ffff86d4224 which contains value a
[hacky Pointer] now points to 0x7ffff86d4225 which contains value b
[hacky Pointer] now points to 0x7ffff86d4226 which contains value c
[hacky Pointer] now points to 0x7ffff86d4227 which contains value d

You have to use an integer type that is able to contain values of pointers. 

