>#include<stdio.h>
>#include<stdlib.h>
>int exterint[5][5];
>int exterint1[5];
>int main(void){
>int index0, index1;
>int **temp1;
>int *temp2;
>temp2=exterint1; //*****
>temp1 = exterint; //xxxxxxxxx
>The compiler will warn me that at line marked as xxxxx is "assignment from
incompatible pointer type."
>But "******" doesn't get any warning.
Here exterint1 is a pointer to the first element of one dimensional array,
which is nothing but an integer. Thus "exterint1" is nothing but simply a
pointer to an integer. Thats why you can assign it "temp2" which is also a
pointer of same type.
But keeping in mind the way two dimensional arrays are treated, "exterint"
is a pointer to an array of integers of size 5. Note that it is not a
pointer to pointer to an integer, while "temp1" is a pointer to pointer to
integer. Thus when in "temp1 = exterint" the assignment is not correct and
hence warning.
To remove it what you can do it, declare "temp1" as a pointer to an array of
integer of size 5. Something like this -
int (*temp1)[5];
temp1 = externint;
Hope it helps.
Best regards
Arvind Sahlot
On 12/26/07, Saquib Imam <[EMAIL PROTECTED]> wrote:
>
> …
>
> int exterint[5][5];
>
> int exterint1[5];
>
> …
>
> int **temp1;
>
> int *temp2;
>
> ….
>
> temp2=exterint1; //*****
>
> temp1 = exterint; //xxxxxxxxx "ERROR GIVING LINE"
>
>
>
> In the above case exterint1 will be pointing to the first element of the
> integer array, so it can be assigned to a integer pointer.
>
>
>
> So the assignment
>
> temp2=exterint1; is correct.
>
>
>
> While in case of exterint , it will be pointing to the first element to
> the first row , again its pointing to a integer not a pointer to the integer
> while temp1 is a pointer to the pointer to an integer.
>
>
>
> So the assignment
>
> temp1 = exterint gives an error.
>
> Thanks & Regards,
>
> Saquib Imam
> ------------------------------
>
> *From:* [EMAIL PROTECTED] [mailto:
> [EMAIL PROTECTED] *On Behalf Of *Cihan Kömeçoglu
> *Sent:* Monday, December 24, 2007 4:26 PM
> *To:* [EMAIL PROTECTED]
> *Cc:* [email protected]
> *Subject:* Re: Question about double pointers assignment
>
>
>
> I think , the problem is there
>
>
>
> temp1 = exterint
>
>
>
> temp1 is pointer to pointer,not pointer to int but you assigned adress of
> exterint1 and this array of integer; not array of pointer.
>
> For example like this give you same warning:
>
>
>
> int * temp1;
>
> int a;
>
> temp1 = a;
>
> Warrning:"assignment from incompatible pointer type
>
>
>
> This is correct if you do like below
>
>
>
> int *temp1
>
> int exterint[5];
>
>
>
> temp1 = exterint;
>
>
>
> Monday, December 24, 2007, 11:49:37 AM, you wrote:
>
>
>
> *>*
>
> Dear all:
>
> I write a program like below:
>
>
>
> #include<stdio.h>
>
> #include<stdlib.h>
>
> int exterint[5][5];
>
> int exterint1[5];
>
> int main(void){
>
> int index0, index1;
>
> int **temp1;
>
> int *temp2;
>
> temp2=exterint1; //*****
>
> temp1 = exterint; //xxxxxxxxx
>
> …..
>
> …..}
>
>
>
> The compiler will warn me that at line marked as xxxxx is "assignment from
> incompatible pointer type."
>
> But "******" doesn't get any warning.
>
>
>
> Is there any restriction about assigning multi-layer array or something
> about pointer I miss?
>
>
>
> Appreciate your help,
>
> cckuo
>
>
>
> ***************** Novatek Email Confidentiality Notice *****************
>
> The information contained in this electronic communication, and any
> electronic attachments, is confidential or legally privileged and may be
> subject to protection under the law. It is intended only for the named
> recipient above. If you have received this communication in error, or are
> not the named recipient, please immediately notify the sender via reply
> email and delete this communication from your computer system, and destroy
> all copies of this communication along with any attachments. Thank you for
> your cooperation.
>
>
>
> Copyright Novatek 2006-2007 All Rights Reserved
>
>
>
>
>
>
>
>
>
> *-- -- To unsubscribe from this list: send an email with "unsubscribe
> kernelnewbies" to [EMAIL PROTECTED] Please read the FAQ at
> http://kernelnewbies.org/FAQ*
>