No.12984
int* foo = NULL;
vs
int *foo = NULL;
Why do some people think that the * belongs to 'foo' instead of 'int'? The type of foo is not int, it's a pointer, the value it has is a memory address, so clearly the * is part of the type. foo is not even defined, it's NULL which makes sense for a pointer, but not for an int.
In fact I think the most logical syntax would be "*int foo = NULL;".
____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.12988
I thought about this before, its due to list declarations.
int* nigger, please; -> implies two pointers
int *nigger, *please; -> probably what you meant
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.12990
>>12984
>in the absolutely rare cases of this:
>int* a, b
>a is a pointer, b is not a pointer
>ideally int *a, *b
not a huge deal, int* is fine but just be wary of that circumstance
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.12993
>>12988
>>12990
I see, I very rarely declare multiple variables in one line like that let alone multiple pointers. Usually I have a struct for 2 closely related variables anyway, for example positions/dimensions.
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
No.13020
>>12984
>int *foo = NULL;
This is the correct way to format it. You should think about the statement as reading "the dereferenced type *foo is an integer." Then declarations like
int *foo, bar;
make sense, because both *foo and bar are integer types.
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.