Pointer * Location

CS50 used to write pointers are Type* var, but changed that to Type *var last year, and although they didn’t really say why, I personally have grown to like t *v better.

Having the * makes it hard to miss. It makes it easier to spot when you’re scanning code for a variable you want to investigate. Because typically, if you’re skimming code for a declaration or ctrl-clicking, you might not always glance at the type immediately. I know it’s only a character away, but with syntax coloring and dark themes, it’s easy to miss the * sometimes. For me, anyways, it helps ensure I don’t miss the fact that it’s a pointer (although the compiler will certainly tell me anyway!)

I’ve really grown to like the type *var style and just wanted to share my reason.

Privacy & Terms