Question: I had been writing things like 

```
char *x=NULL;

```

on the assumption that 

```
 char *x=2;

```

would create a `char` pointer to address 2. 

But, in [The GNU C Programming Tutorial](http://www.crasseux.com/books/ctutorial/Pointers-and-initialization.html#Pointers%20and%20initialization) it says that `int *my_int_ptr = 2;` stores the integer value `2` to whatever random address is in `my_int_ptr` when it is allocated.

This would seem to imply that my own `char *x=NULL` is assigning whatever the value of `NULL` cast to a `char` is to some random address in memory.

While

```
#include <stdlib.h>
#include <stdio.h>

int main()
{
    char *x=NULL;

    if (x==NULL)
        printf("is NULL\n");

    return EXIT_SUCCESS;
}

```

does, in fact, print 

> 
> is NULL
> 
> 
> 

when I compile and run it, I am concerned that I am relying on undefined behavior, or at least under-specified behavior, and that I should write

```
char *x;
x=NULL;

```

instead.

Answer: 
This is correct.

```
int main()
{
    char * x = NULL;

    if (x==NULL)
        printf("is NULL\n");

    return EXIT_SUCCESS;
}

```

This function is correct for what it does. It assigns the address of 0 to the char pointer x. That is, it points the pointer x to the memory address 0.

Alternative:

```
int main()
{
    char* x = 0;

    if ( !x )
        printf(" x points to NULL\n");

    return EXIT_SUCCESS;
}

```

My guess as to what you wanted is:

```
int main()
{
    char* x = NULL;
    x = alloc( sizeof( char ));
    *x = '2';

    if ( *x == '2' )
        printf(" x points to an address/location that contains a '2' \n");

    return EXIT_SUCCESS;
}

x is the street address of a house. *x examines the contents of that house.

```
this is a null pointer

```
int * nullPtr = (void*) 0;

```