assianing value of pointer

J

James Kuyper

is it a valid statement if no y

What does 'y' have to do with it?
int *p=&x, x;

First of all, that's a pair of declarations, it's not a statement.
Secondly, unless there's prior declaration of x that will end up being
hidden by this one, you're trying to use 'x' before it's been declared.
That's easily fixed:

int x, *p=&x;
 
K

Keith Thompson

James Kuyper said:
What does 'y' have to do with it?

I think the OP meant:

Is it a valid statement? If not, why?

Note to vj: Please don't use silly abbreviations like 'y' for "why".
First of all, that's a pair of declarations, it's not a statement.
Secondly, unless there's prior declaration of x that will end up being
hidden by this one, you're trying to use 'x' before it's been declared.
That's easily fixed:

int x, *p=&x;

Or, even better:

int x;
int *p = &x;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,951
Messages
2,570,113
Members
46,699
Latest member
Abigail89S

Latest Threads

Top