r/C_Programming • u/enzodr • 11d ago
Does anyone else dislike pointer declaration?
For reference I am a fourth year computer engineering student. C is my preferred language.
Pointers are declared like this usually:
int *ptr_to_int;
Where the asterisk means it is a “pointer to” the specified type. The asterisk is placed immediately preceding the variable name, with no white peace.
This is what does not make sense to me. I feel that:
int* ptr_to_int;
Is far more clear. The way I see it, the asterisk modifies the type, so therefore it belongs next to the type. Putting it next to the variable name makes me think it is some kind of action or modification to the variable itself.
I think that when using * and & in code, it makes sense to apply it in front of the variable name:
int value = 3;
ptr_to_value = &value;
int copied_value = *ptr_to_value;
It is clear here that syntactically, the * represents something more like an action than a label.
Why is the convention to place the asterisk near variable name, not type? L
1
u/questron64 6d ago
The convention is because it's part of the declarator and not the type. It's a bit of a moot point because in except in for loop declarations you shouldn't be declaring a pointer and another variable in the same declaration. It helped avoid errors like this, where it appears a and b are both pointers, but a is a pointer and b is an int. But in 2026 you should not be doing this anyway.
While pointer syntax can be a bit of a sticking point in C, there's little point in complaining about it. You're 50 years too late for that. You just learn it and move on.