No, a=b is NOT the same as *a=*b.

Here are some examples that may help:

int   x;    // X is an integer.  Current value of X is undefined.
int   y;    // Y is an integer.  Current value of Y is undefined.

int  *a;    // A is a pointer to an integer.  Current value of A is undefined.
int  *b;    // A is a pointer to an integer.  Current value of B is undefined.

x = 123;    // X is now 123.
y = 456;    // Y is now 456.

a = NULL;   // A is now NULL or 0 meaning A points at 0.  *A is whatever int 
lies at 0.

a = x;      // This statement is illegal and the compiler should complain.

a = &x;     // A points at X.  *A is 123 which is the value of X.

b = &y;     // B points at Y.  *B is 456 which is the value of Y.

a = b;      // A now points at Y which is what B was pointing at.  *A is now 
456.

*a = 789;   // 789 is assigned to what A points at which is Y.  Y is now 789.



[email protected] wrote:
> Hello again.
> and thanks for all the answers !!
> 
> continuing from my question-
> is a=b the same like *a=*b ??
> *a == &a ? and *b==&b or I got it all mixed up?
> if a and b were initialized in the begining with NULL(\0),
> what was the difference ?
> 
> --- In [ mailto:c-prog%40yahoogroups.com [EMAIL PROTECTED], Jim Dougherty
> <[EMAIL PROTECTED]> wrote:
>>
>>
>> [ mailto:c-prog%40yahoogroups.com [EMAIL PROTECTED] wrote:
>>> [ mailto:c-prog%40yahoogroups.com ][ mailto:c-prog%40yahoogroups.com
> [EMAIL PROTECTED] wrote:
>>>> defined -
>>>> int *a,*b;
>>>>
>>>> what's the difference between:
>>>>
>>>> 1. *a=b;
>>> Here, the location pointed to by A (which is an INT) 
>>> is set to the contents of pointer B (which is a pointer to an 
> INT).
>>> Note: the compiler should give you an error/warning about this.
>>>
>>>> 2. a=b;
>>> Here, the pointer A (which is a pointer to an INT) 
>>> is set to the contents of the pointer B (which is a pointer to an 
> INT).
>>
>> Maybe what you intended but did not specify was:
>>
>> *a = *b;
>>
>> Here, the location pointed to by A (which is an INT)
>> is set to the contents of the location pointed to by B (which is an 
> INT).
> 
> 
> 
> 
>  
> 
> 



To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/c-prog/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/c-prog/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to