Earlier quoted context omitted.
Besides writing "int *p" instead of "int* p" I also always use one line per variable declaration, which should avoid confusion when the first style is used. But that's my personal preference. Edit: corrected code quotation.
When quoting code, leave a line and indent by two spaces.
Everything you need to know about pointers in C (2010)
21–25 of 25 posts
Re: Everything you need to know about pointers in C (2010)
#22The time [0] I found out about ptr_b in int* ptr_a, ptr_b; isn't actually initialized as a pointer I changed all my C code to marking * before the variable name, fun times. It's helpful to think int as the base type and * the indicator of functionality like [] and (). Also just found out the author was the developer of Adium [1], which is one of my favorite softwares (best logo) on macOS. [0] http://c-faq.com/decl/ch…
Re: Everything you need to know about pointers in C (2010)
#23> void pointers are incremented or decremented by 1 byte. No, void pointer arithmetic is not allowed by the C standard: https://stackoverflow.com/questions/3523145/pointer-arithmet...
That answer does mention that GCC permits it as an extension. If the author uses GCC, maybe that’s where the confusion comes from?
OTOH, GCC documentation says "sizeof is also allowed on void and on function types, and returns 1".
Re: Everything you need to know about pointers in C (2010)
#24Re: Everything you need to know about pointers in C (2010)
#25The time [0] I found out about ptr_b in int* ptr_a, ptr_b; isn't actually initialized as a pointer I changed all my C code to marking * before the variable name, fun times. It's helpful to think int as the base type and * the indicator of functionality like [] and (). Also just found out the author was the developer of Adium [1], which is one of my favorite softwares (best logo) on macOS. [0] http://c-faq.com/decl/ch…
Besides writing "int *p" instead of "int* p" I also always use one line per variable declaration, which should avoid confusion when the first style is used. But that's my personal preference. Edit: corrected code quotation.