-2

I have struct:

struct stek
{
char value;
struct stek *next; 
};

Why i can init this like this:

stek *p = 0;

What this mean? Why zero?

Admiral Land
  • 2,304
  • 7
  • 43
  • 81

2 Answers2

2

tldr; Because 0 is a valid memory address.


Since pointers point to memory locations, the expression is valid and p points to memory address 0

smac89
  • 39,374
  • 15
  • 132
  • 179
1

Here 0 means NULL. In prior C++11, 0 can be used as NULL which is pretty ambiguous sometimes. Currently C++ has nullptr which makes more sense.

Read more about difference between NULL and nullptr.

Kaidul
  • 15,409
  • 15
  • 81
  • 150