this post was submitted on 02 Feb 2024
295 points (96.8% liked)

Programmer Humor

19187 readers
1122 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 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 58 points 7 months ago (26 children)

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

[–] [email protected] 87 points 7 months ago* (last edited 7 months ago) (8 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.

[–] [email protected] 56 points 7 months ago

Yeah, and I'd say that's a design flaw of the language as it is unintuitive behaviour.

load more comments (7 replies)
load more comments (24 replies)