this post was submitted on 02 Feb 2024
275 points (96.6% liked)

Programmer Humor

25460 readers
1042 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] blackstrat@lemmy.fwgx.uk 58 points 2 years ago (23 children)

The fact it's a pointer is part of the type, not part of the variable name. So int* p is the way.

[–] sweng@programming.dev 81 points 2 years ago* (last edited 2 years ago) (5 children)

You would think so, but int* a, b is actually eqivalent to int* a; int b, so the asterisk actually does go with the name. Writing int* a, *b is inconsistent, so int *a, *b is the way to go.

[–] CanadaPlus@futurology.today 8 points 2 years ago

Alright, I'll never, ever write something this way now. Good to know.

load more comments (4 replies)
load more comments (21 replies)