1

so I recently started learning pointers and in a lot of examples they are using flower brackets like this

int *iPtr{}; // a pointer to an integer value
double *dPtr{}; // a pointer to a double value
 
int* iPtr2{}; // also valid syntax (acceptable, but not favored)
int * iPtr3{}; // also valid syntax (but don't do this, it looks like multiplication)
 
int *iPtr4{}, *iPtr5{}; // declare two pointers to integer variables (not recommended)

I just want to know is it important to add those brackets

cigien
  • 57,834
  • 11
  • 73
  • 112
BeastKing
  • 19
  • 1
  • 2
    Does this answer your question? [What do curly braces after a struct variable member mean?](https://stackoverflow.com/questions/61520931/what-do-curly-braces-after-a-struct-variable-member-mean) – Jeremy Friesner Dec 11 '20 at 06:20

1 Answers1

2

Those are for initialization. You can also initialize it by doing int *Iptr = NULL; or even initialize it to any other valid address if you want.
If you don't do the initialization then it will be undefined, and will cause problems if you accidentally access it.