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: 
The tutorial is wrong. In ISO C, `int *my_int_ptr = 2;` is an error. In GNU C, it means the same as `int *my_int_ptr = (int *)2;` . This converts the integer `2` to a memory address, in some fashion as determined by the compiler.

It does not attempt to store anything in the location addressed by that address (if any). If you went on to write `*my_int_ptr = 5;`, then it would try to store the number `5` in the location addressed by that address.
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.

```