17 ms·
I'm probably misunderstanding you, but can I rephrase your comment as saying 'int i is the natural way of declaring a pointer to an int, and not int i'? Because
by roel_v 10y ago
I'm probably misunderstanding you, but can I rephrase your comment as saying 'int i is the natural way of declaring a pointer to an int, and not int i'? Because if so, I don't recall that from the K&R (and I've read it front to back several times, not that that means much - I can't even remember if they use int* i or int *i, and I don't have my copy at hand here).
- munificent 10y agoAlas, HN mangled your asterisks. > I don't recall that from the K&R I don't recall either, but this Wikipedia mention of "declaration reflects use" cites K&R: https://en.wikipedia.org/wiki/C_%28programming_language%29#Criticism https://en.wikipedia.org/wiki/C_%28programming_language%29#C...
- roel_v 10y agoUh sorry, the first one had the asterisk next to the variable name, the other next to the type. Yes I agree about the 'declaration reflects use'; what I meant was: does that imply that the declaration should consider the asterisk (the 'make this a pointer' part) to be 'part of', and thus right next to, the variable name or the type? I'm strongly in the 'type' camp myself, and therefore I think that int *p; is nonsense; only to be used out of necessity when declaring multiple pointer variables on one line. So I'm wondering if 'declaration reflects use' reaffirms that, or contradicts it.