Pointer question?

R

rattan

Assume the following codce (line numbers of reference only, compiler
gcc-3.4):

1 int a[3] = {2, 2, 3}, **ptr;
2 int sumit(int **, int);

calling sumit:

3 sumit(&a, 3);
or
4 *ptr = a; sumit(ptr, 3);

call on line 3 produces incompatible type pointers warning
but on line 4 does not.

So, what is the difference between the two calls?

-ishwar
 
E

Eric Sosman

Assume the following codce (line numbers of reference only, compiler
gcc-3.4):

1 int a[3] = {2, 2, 3}, **ptr;
2 int sumit(int **, int);

calling sumit:

3 sumit(&a, 3);
or
4 *ptr = a; sumit(ptr, 3);

call on line 3 produces incompatible type pointers warning
but on line 4 does not.

So, what is the difference between the two calls?

This is Question 6.18 in the comp.lang.c Frequently
Asked Questions (FAQ) list

http://www.c-faq.com/
 
B

Barry Schwarz

Assume the following codce (line numbers of reference only, compiler
gcc-3.4):

1 int a[3] = {2, 2, 3}, **ptr;
2 int sumit(int **, int);

calling sumit:

3 sumit(&a, 3);
or
4 *ptr = a; sumit(ptr, 3);

While this may be correct syntactically, it invokes undefined
behavior.
call on line 3 produces incompatible type pointers warning
but on line 4 does not.

So, what is the difference between the two calls?

What is the type of a? What is the type of &a?


Remove del for email
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top