We help IT Professionals succeed at work.
Get Started

C: Passing array  to function vs. passing a POINTER to the same array

Stephen Kairys
on
548 Views
Last Modified: 2012-08-14
Hey everyone,
I'm telling myself the following MUST be OK but have a nagging doubt so I want to be sure. :)

In C:

1. SupposeI have a structure: CUSTOMER
and an array: (Global to my C file)
CUSTOMER  People[100];

2. I then have (local to function in the same C file):
CUSTOMER *PtrPeople = People;

3. Now I have a called functon whose header is:
void ProcessStuff (PEOPLE *ppl)

4. My exis ting code (which someone else wrote) has the following calls:
ProcessStuff(People);  // call #1, using the array
and
ProcessStuff(PtrPeople); // call #2 using the ptr to the array.

From what I recall, these should be one and the same since I'm dealing with an ARRAY,
but would appreciate either confirmation or correcting me if I'm wrong.

Thanks
Steve
Comment
Watch Question
This problem has been solved!
Unlock 2 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE