Home Segments Index Top Previous Next

332: Mainline

You can place the asterisk in pointer-variable definitions or pointer-parameter declarations just after the data type, just before the variable or parameter, or with space in between. Thus, all the following produce the same result:

struct trade *tptr; 
struct trade* tptr; 
struct trade * tptr; 

Some programmers prefer to join the asterisk to the variable as a prefix, because that approach places the asterisk in the same position when the pointer is introduced and when the pointer is used. Others prefer to join the asterisk to the data type as a suffix, because they see the asterisk as a data-type modifier. Few like to put the asterisk in between, with spaces on both sides, because that looks too much like multiplication.