Online PC Builder
EMI
Best Selling - SAHARA LAPTOP
Lenovo Laptops
Reliance WiFi Data Card
Microsoft Office 2007
Board index
LoginLogin User Control PanelUser Control Panel 
  FAQFAQ SearchSearch  
SwamiPC Sahara Scratch Offer

What is the fundamental difference between pointer and array

C Programming

What is the fundamental difference between pointer and array

Postby Sumit on Wed Aug 29, 2007 3:49 pm

I'm struggling to understand the difference between a pointer and array. And when to use which?

Any help.
Thanks.
Sumit
Sumit
 
Posts: 1
Joined: Wed Aug 29, 2007 3:30 pm

Re: What is the fundamental difference between pointer and a

Postby cppguru on Wed Aug 29, 2007 3:59 pm

Sumit wrote:I'm struggling to understand the difference between a pointer and array. And when to use which?

Any help.
Thanks.
Sumit


Boy you need to do homework. Read K&R's C Programming Language, aka The C Bible.

I would make your life easier just remember these 2 definitions

Array: A variable which has same type of elements in it.
Pointer: A variable which contains address of another variable.

They can be used interchangeably, you can use any of them to achieve same purpose.

But when it comes to use them pointers go messy.

Welcome to the "C" world.
cppguru
 
Posts: 4
Joined: Mon Apr 16, 2007 11:40 am

Re: What is the fundamental difference between pointer and a

Postby SpiritOfIndia on Wed Aug 29, 2007 4:12 pm

cppguru wrote:They can be used interchangeably, you can use any of them to achieve same purpose.


int *ptr;

int a[10];

ptr = &a;

It is a puzzle solve it ;) Want to make complex? Try this

*ptr = a;
SpiritOfIndia
 
Posts: 12
Joined: Mon Apr 16, 2007 11:47 am


Return to C Programming

Who is online

Users browsing this forum: No registered users and 0 guests

phpBB SEO

SAIPL - Career
SwamiPC - Career
International Jobs
Jobs for Fresher
Referral Offer
Microsoft Vista