can I assign a consistant to a pointer varible? like
int *p;
*p = 13;
???
or can i use pointer like this:
int *p;
int e = 13;
*p == e;
thanks for your help!can I assign a consistant to a pointer varible? like
This is a discussion on question about pointer? within the C Programming forums, part of the General Programming Boards category; can I assign a consistant to a pointer varible? like int *p; *p = 13; ??? or can i use ...
can I assign a consistant to a pointer varible? like
int *p;
*p = 13;
???
or can i use pointer like this:
int *p;
int e = 13;
*p == e;
thanks for your help!can I assign a consistant to a pointer varible? like
A variable holds an address, if you can print out the address of what you want the pointer to point to then you can assign it to a pointer.
printf ( "%d", &13 );
would flag an error, so you can't assign a constant to a pointer unless it can be used as an address itself. In that case you would use the syntax
ptr = 0x08;
or something similar
-Prelude
My best code is written with the delete key.
>can I assign a consistant to a pointer varible? like
>int *p;
>*p = 13;
>???
No, p must point to something first.
>or can i use pointer like this:
>int *p;
>int e = 13;
>*p == e;
No, but you can do this:
int *p;
int e = 13;
p = &e; //point p to e