0

Hi,

Can anyone explain in detail what is the difference between int *a and int* a? Is there any difference between them?

4
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by Ancient Dragon
Featured Replies
  • [QUOTE=Perry31;1389681]Hi, Can anyone explain in detail what is the difference between int *a and int* a? Is there any difference between them?[/QUOTE] No difference.. But it is better do it 'int *a;' because of readability and is more understandable. Eg: Suppose the statement is [CODE]int* a, b;[/CODE] it is actually … Read More

2

Hi,

Can anyone explain in detail what is the difference between int *a and int* a? Is there any difference between them?

No difference.. But it is better do it 'int *a;' because of readability and is more understandable.

Eg: Suppose the statement is

int* a, b;

it is actually equivalent to

int *a;
int b;

not

int *a;
int *b

If we had written the original statement as

int *a,b;

this would have been more obvious to someone who reads it who is a new bie.

Votes + Comments
I agree
0

Hey Perry 31,
I recently was reading up on white space rules for C. From what I gathered, tokens such as variable names, function names, variable data type names, other important words in the language, when in contact with operators are naturally separated.

Because of the phenomenon being true that int *var; is syntactically equivalent to int* var;, int*var;, and int<any number spaces>*<any number spaces>var;,I would suffice it to say that the pointer is considered an operator, which would explain why the organization does not and will never have an effect on the functionality when you, I, or anyone else are programming.

Edited by Jmknight: n/a

0

Hey Perry 31,
I recently was reading up on white space rules for C. From what I gathered, tokens such as variable names, function names, variable data type names, other important words in the language, when in contact with operators are naturally separated.

Because of the phenomenon being true that int *var; is syntactically equivalent to int* var;, int*var;, and int<any number spaces>*<any number spaces>var;,I would suffice it to say that the pointer is considered an operator, which would explain why the organization does not and will never have an effect on the functionality when you, I, or anyone else are programming.

In otherwords, to boil down that long-winded post, the answer is like I said before, There is no difference.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.