Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > What's the position of pointers

Reply
Thread Tools

What's the position of pointers

 
 
Yee.Chuang
Guest
Posts: n/a
 
      09-11-2008
When I began to learn C, My teacher told me that pointer is the most
difficult part of C, it makes me afraid of it. After finishing C
program class, I found that all the code I wrote in C contains little
pointers, obviously I avoid using them.
A few days ago when I was reading a book about programming, I was told
that pointers are the very essence of C language, if I couldn't use it
well, I'm a bad programmer, it's a big shock.
So now I'm wondering: what's the exact position of pointers in C? Is
it really necessary to learn how it works again?
 
Reply With Quote
 
 
 
 
Stephen Sprunk
Guest
Posts: n/a
 
      09-11-2008
Yee.Chuang wrote:
> When I began to learn C, My teacher told me that pointer is the most
> difficult part of C, it makes me afraid of it. After finishing C
> program class, I found that all the code I wrote in C contains little
> pointers, obviously I avoid using them.


That's pretty much what happened with me; I came from a Pascal
background where I had used pointers once or twice in several years, and
before that BASIC, which didn't even have the concept at all.

What's funny is that, when I finally forced myself to learn, pointers
turned out to be a lot easier to deal with than I expected. There just
aren't many good books that teach it right, nor teachers who really
understand it well enough to explain it well to students.

> A few days ago when I was reading a book about programming, I was told
> that pointers are the very essence of C language, if I couldn't use it
> well, I'm a bad programmer, it's a big shock.


I have to agree with that.

> So now I'm wondering: what's the exact position of pointers in C? Is
> it really necessary to learn how it works again?


You really can't unlock the power that C offers without understanding
and using pointers. If you don't, you're really just writing Pascal
that looks like C.

S
 
Reply With Quote
 
 
 
 
CBFalconer
Guest
Posts: n/a
 
      09-11-2008
Stephen Sprunk wrote:
> Yee.Chuang wrote:
>
>> When I began to learn C, My teacher told me that pointer is the
>> most difficult part of C, it makes me afraid of it. After
>> finishing C program class, I found that all the code I wrote in
>> C contains little pointers, obviously I avoid using them.

>
> That's pretty much what happened with me; I came from a Pascal
> background where I had used pointers once or twice in several
> years, and before that BASIC, which didn't even have the concept
> at all.


Then you weren't using Pascal thoroughly. The prime uses of
pointers are very similar between Pascal and C, but Pascal doesn't
allow the loose generic conversion of VAR parameters to pointers,
and similar things for arrays, etc. This allows Pascal to check
for most common errors, unlike C.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
 
Reply With Quote
 
August Karlstrom
Guest
Posts: n/a
 
      09-11-2008
Yee.Chuang wrote:
> When I began to learn C, My teacher told me that pointer is the most
> difficult part of C, it makes me afraid of it. After finishing C
> program class, I found that all the code I wrote in C contains little
> pointers, obviously I avoid using them.
> A few days ago when I was reading a book about programming, I was told
> that pointers are the very essence of C language, if I couldn't use it
> well, I'm a bad programmer, it's a big shock.
> So now I'm wondering: what's the exact position of pointers in C? Is
> it really necessary to learn how it works again?


In general you need pointers to build dynamic data structures like
linked lists. In C you also need pointers to simulate call by reference.


August
 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      09-12-2008
On 11 Sep, 22:28, CBFalconer <cbfalco...@yahoo.com> wrote:
> Stephen Sprunk wrote:
> > Yee.Chuang wrote:


> >> When I began to learn C, My teacher told me that pointer is the
> >> most difficult part of C, it makes me afraid of it. *After
> >> finishing C program class, I found that all the code I wrote in
> >> C contains little pointers, obviously I avoid using them.

>
> > That's pretty much what happened with me; I came from a Pascal
> > background where I had used pointers once or twice in several
> > years, and before that BASIC, which didn't even have the concept
> > at all.

>
> Then you weren't using Pascal thoroughly. *The prime uses of
> pointers are very similar between Pascal and C, but Pascal doesn't
> allow the loose generic conversion of VAR parameters to pointers,
> and similar things for arrays, etc. *This allows Pascal to check
> for most common errors, unlike C.


yes I moved from pascal to C and didn't find pointers a problem.
They seemed very like pascal pointers. Though I thought the sysntax
was *very* strange!

On the other hand I'd programmed in Coral, Assmebler and had
brief exposure to BCPL. So pointers seemed quite normal!


--
Nick Keighley

Unicode is an international standard character set that can be used
to write documents in almost any language you're likely to speak,
learn or encounter in your lifetime, barring alien abduction.
(XML in a Nutshell)
 
Reply With Quote
 
Yee.Chuang
Guest
Posts: n/a
 
      09-12-2008
On Sep 12, 5:03*pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
wrote:
> On 11 Sep, 22:28, CBFalconer <cbfalco...@yahoo.com> wrote:
>
>
>
> > Stephen Sprunk wrote:
> > > Yee.Chuang wrote:
> > >> When I began to learn C, My teacher told me that pointer is the
> > >> most difficult part of C, it makes me afraid of it. *After
> > >> finishing C program class, I found that all the code I wrote in
> > >> C contains little pointers, obviously I avoid using them.

>
> > > That's pretty much what happened with me; I came from a Pascal
> > > background where I had used pointers once or twice in several
> > > years, and before that BASIC, which didn't even have the concept
> > > at all.

>
> > Then you weren't using Pascal thoroughly. *The prime uses of
> > pointers are very similar between Pascal and C, but Pascal doesn't
> > allow the loose generic conversion of VAR parameters to pointers,
> > and similar things for arrays, etc. *This allows Pascal to check
> > for most common errors, unlike C.

>
> yes I moved from pascal to C and didn't find pointers a problem.
> They seemed very like pascal pointers. Though I thought the sysntax
> was *very* strange!
>
> On the other hand I'd programmed in Coral, Assmebler and had
> brief exposure to BCPL. So pointers seemed quite normal!
>
> --
> Nick Keighley
>
> Unicode is an international standard character set that can be used
> to write documents in almost any language you're likely to speak,
> learn or encounter in your lifetime, barring alien abduction.
> * * * * * * *(XML in a Nutshell)


Something I forgot to tell: C is the first language I've learned,
after that I understand the basic skills of programming. Most of the
time I just use software like SAS, Matlab and R to solve problems.
Yes, I don't write any software, I just use them.
If learning pointers can help me with programing thoughts or improve
my program skills, I'm glad to do so.
 
Reply With Quote
 
vippstar@gmail.com
Guest
Posts: n/a
 
      09-12-2008
On Sep 12, 12:20 pm, "Yee.Chuang" <mcdrag...@gmail.com> wrote:
> On Sep 12, 5:03 pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
> wrote:
>
> > On 11 Sep, 22:28, CBFalconer <cbfalco...@yahoo.com> wrote:

>
> > yes I moved from pascal to C and didn't find pointers a problem.
> > They seemed very like pascal pointers. Though I thought the sysntax
> > was *very* strange!

>
> > On the other hand I'd programmed in Coral, Assmebler and had
> > brief exposure to BCPL. So pointers seemed quite normal!

>
> Something I forgot to tell: C is the first language I've learned,
> after that I understand the basic skills of programming. Most of the
> time I just use software like SAS, Matlab and R to solve problems.
> Yes, I don't write any software, I just use them.
> If learning pointers can help me with programing thoughts or improve
> my program skills, I'm glad to do so.


Pointers are not a unique concept in C.
A pointer points to something. You can access that something via the
pointer.
That's all there is to it, as a generic concept.

Now, if you want to learn C pointers, first you'd have to understand
C's type system.
Given that p is char [4][2], you should immediately be able to tell
which type *p is, p[0][0], &p[0].
(answer: char [2], char, char (*)[2])

That's half the work. The other half is to read the semantics of
pointers.

HTH.
 
Reply With Quote
 
Richard
Guest
Posts: n/a
 
      09-12-2008
writes:

> On Sep 12, 12:20 pm, "Yee.Chuang" <mcdrag...@gmail.com> wrote:
>> On Sep 12, 5:03 pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
>> wrote:
>>
>> > On 11 Sep, 22:28, CBFalconer <cbfalco...@yahoo.com> wrote:

>>
>> > yes I moved from pascal to C and didn't find pointers a problem.
>> > They seemed very like pascal pointers. Though I thought the sysntax
>> > was *very* strange!

>>
>> > On the other hand I'd programmed in Coral, Assmebler and had
>> > brief exposure to BCPL. So pointers seemed quite normal!

>>
>> Something I forgot to tell: C is the first language I've learned,
>> after that I understand the basic skills of programming. Most of the
>> time I just use software like SAS, Matlab and R to solve problems.
>> Yes, I don't write any software, I just use them.
>> If learning pointers can help me with programing thoughts or improve
>> my program skills, I'm glad to do so.

>
> Pointers are not a unique concept in C.
> A pointer points to something. You can access that something via the
> pointer.
> That's all there is to it, as a generic concept.
>
> Now, if you want to learn C pointers, first you'd have to understand
> C's type system.
> Given that p is char [4][2], you should immediately be able to tell
> which type *p is, p[0][0], &p[0].
> (answer: char [2], char, char (*)[2])


"p is char[4][2]"? I know pointers and I dont understand your example or
what you are trying to say.
 
Reply With Quote
 
Bartc
Guest
Posts: n/a
 
      09-12-2008

<> wrote in message
news:5f81dfd1-8ea5-4b9e-962d-...
> On Sep 12, 12:20 pm, "Yee.Chuang" <mcdrag...@gmail.com> wrote:


>> Something I forgot to tell: C is the first language I've learned,
>> after that I understand the basic skills of programming. Most of the
>> time I just use software like SAS, Matlab and R to solve problems.
>> Yes, I don't write any software, I just use them.
>> If learning pointers can help me with programing thoughts or improve
>> my program skills, I'm glad to do so.

>
> Pointers are not a unique concept in C.
> A pointer points to something. You can access that something via the
> pointer.
> That's all there is to it, as a generic concept.


Not quite. Those other languages use pointers behind the scenes, they
already have the 'something'.

C needs pointers just to implement those 'something's in the first place, or
to push them around. They're not an optional extra, not for dealing with
dynamic or flexible data.

> Now, if you want to learn C pointers, first you'd have to understand
> C's type system.
> Given that p is char [4][2], you should immediately be able to tell
> which type *p is, p[0][0], &p[0].
> (answer: char [2], char, char (*)[2])


I wouldn't frighten off the OP with this stuff. I don't understand half of
it either.

--
Bartc

 
Reply With Quote
 
Pilcrow
Guest
Posts: n/a
 
      09-12-2008
On Thu, 11 Sep 2008 12:41:13 +0000, Richard Heathfield
<> wrote:

>Yee.Chuang said:
>
>> When I began to learn C, My teacher told me that pointer is the most
>> difficult part of C,

>
>He probably told you that not because they're hard to learn (they aren't!),
>but because they're hard to teach!
>

Maybe pointers were mysterious to him. Or he felt them too dangerous
for a beginner, which we hear often. But we learn best by making
mistakes and then correcting them. Taking risks is the best part of
living.

>> it makes me afraid of it.

Overcoming your fears is glorious!

>
>Yes, you're not alone. But it's worth overcoming that fear, because
>pointers are the very essence of the C language. And once you "get" them,
>your eyes will light up, and the word "POWER!" will pop into your head,
>and there'll be no stopping you.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pointers, pointers, pointers... cerr C Programming 12 04-07-2011 11:17 PM
detecting mouse click position in canvas tag has position off James Black Javascript 0 05-28-2006 03:27 AM
Where is Form Relative Position and Absolute Position in VS.Net 2005 ? Luqman ASP .Net 1 02-07-2006 10:27 AM
position image based on document position edouard.lauer@pt.lu Javascript 3 01-14-2006 06:04 PM
How to set position of a web control depending on other control's position at run-time? James Wong ASP .Net Web Controls 4 07-14-2004 10:24 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57