Is there any difference between dlearations int* x and int
*x? If so tell me the difference?
Answers were Sorted based on User's Feedback
Answer / steve
I think there is no difference.
Also,
Case 1:
int* x,y,z;
and
Case2:
int *x,y,z;
these two cases are exactly same.
In both cases, y and z are not pointers. They are int.
| Is This Answer Correct ? | 32 Yes | 4 No |
Answer / gopinath das
All the above answers are wrong.
There is no difference between int *x and int* x;
Also there is no agreement on waht is the best practice. It
depends on the organizations coding standard.
Even we can write int*x. But this is not a good practice.
| Is This Answer Correct ? | 31 Yes | 4 No |
Answer / sandy
NO difference
Case 1:
int* x,y,z;
and
Case2:
int *x,y,z;
these two cases are also exactly same.
| Is This Answer Correct ? | 12 Yes | 2 No |
Answer / sivaraj
There is no difference i verified this with programming....
Do not confuse with other answers....
| Is This Answer Correct ? | 10 Yes | 1 No |
Answer / uma sankar pradhan
There is no difference between int* x and int *x
Because in C,the number of spaces between two literals
doesnot mean anything.
example,
a+b is same as a + b or a+ b or a +b
| Is This Answer Correct ? | 11 Yes | 3 No |
Answer / anu
i think there is no difference its correct, both are same
| Is This Answer Correct ? | 10 Yes | 2 No |
Answer / foo
The difference is that in the first case the space is after
the * and in the second case the space is before.
Functionally there is no difference.
Arguably int* x is slightly worse since (as other answers
demonstrate) people can misinterpret "int* i, j" as
declaring two pointers-to-int where "int *i, j" is perhaps a
bit clearer.
Practically, you should adopt whatever style is required by
wherever you work or whomever you work with.
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / praveen verma
I think there is no difference.
There is no difference between int *x and int* x;
Also there is no agreement.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / debendra nath tiwary
there is no difference between them here.
but difference comes how we use them.
(int*) can be used for typecasting.
(int *x) is used for declaration purpose. here x is declared as pointer variable.
even if declare like (int* x) is valid but not a formal way to
to declare pointer variable.
| Is This Answer Correct ? | 0 Yes | 0 No |
Explain "const" reference arguments in function?
What is the difference between delegation and implemented-in-terms-of?
Explain how we implement exception handling in c++?
How much maximum can you allocate in a single call to malloc()?
When is dynamic checking necessary?
Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.
Explain the difference between class and struct in c++?
Name the operators that cannot be overloaded in C++?
What is the difference between cin.read() and cin.getline()?
What do you mean by translation unit in c++?
C is to C++ as 1 is to a) What the heck b) 2 c) 10
Assume an array of structure is in order by studentID field of the record, where student IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to find the record with a specific studentID if every single student ID from 101 to 500 is used and the array has 400 elements. Write the most efficient pseudocode algorithm you can to find a record with a studentID near the end of the IDs, say in the range from 450 to 500, if not every single student ID in the range of 101 to 500 is used and the array size is only 300