When I try to declare a pointer in VS 2019, the asterisk automatically moves to the pointer's type side. I know this works too, but it bugs me.
// How it shows:
int* number1{};
// How i want it to show:
int *number2{};
Is there a way I can change that?
Pointers must be declared before they can be used, just like a normal variable. The syntax of declaring a pointer is to place a * in front of the name. A pointer is associated with a type (such as int and double ) too.
If you see the * in a declaration statement, with a type in front of the *, a pointer is being declared for the first time. AFTER that, when you see the * on the pointer name, you are dereferencing the pointer to get to the target.
When declaring a pointer type, place the asterisk next to the type name. Although you generally should not declare multiple variables on a single line, if you do, the asterisk has to be included with each variable.
First, declaring a pointer variable: char *ptr; This declaration tells us the pointer type (char), pointer level ( * ), and variable name ( ptr ).
Please have a look at the available options in menu [Tools] -> [Options] -> [Text Editor] -> [C/C++] -> [Formatting] -> [Spacing] -> [Pointer/Reference alignment].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With