But if you don't want to place the * before the name, it's better to put each pointer on a separate row. Consistency is the argued most important thing. So pick the one you feel most comfortable with and stick with it.

Originally Posted by transgalactic2

whats the result of

Code:

int* ptr_a, ptr_b;

the astrix near the int

what will be the result of such line?

ptr_a will be of type int*, ptr_b will be of type int.

Originally Posted by Adak

io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.

Originally Posted by Salem

You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

The fact is, it precedes the variable name. Somewhere. With or without misdirecting spaces. If you want a second pointer, it too needs to be preceded by an asterisk. You'd never realize that using Elysia's misinterpretation of pointer declaration.

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.

Thank you, laserlight... It helped me understand where int* p comes from. I'm not a C++ person. I was about to post the following in response to Elysia:

The pitfall, if any, appears to be that you've settled on a syntactical foible that implies some associativity of basic C data type with the pointer indicator. This causes you to make strange recommendations about separate lines.

But now I realize there is a reason. But I took a long time to compose the above so I thought I'd voice it anyhow for posterity.

Nevertheless, this is not associated with C++. This style is equally valid in C and any good book should line out both alternatives, leaving the programmer to choose their preferred style.
But it's true that I heavily prefer emphasis on pointers binding to the types due to my C++ background.
Nevertheless it's a good advice, really, since defining pointers on separate lines avoids confusion and people thinking that you've made a (probable) error (as Bjarne clearly lines out in his faq).

And actually, I was looking for that article when replying earlier, but couldn't actually find it due to only bjarne's last name was in the title, so Firefox wouldn't find it. I bookmarked it now, so no problems now!

Originally Posted by Adak

io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.

Originally Posted by Salem

You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.