C pointers: the 5-minute guide

Credit: flickr/adactio

Dennis Kubes, a Texas coder who specializes in realtime search, offers up a C tutorial.

Programming in C can be tough for those new to the language, so Dennis Kubes wrote "The 5-minute Guide to C Pointers," and put it on his blog. Only four code snippets are needed for Kubes to illustrate his tutorial.

Those wishing an expanded overview should look at a video from simplcool titled "tutorial pointers in c++ part1" on YouTube. This almost eight-minute video covers C and C++, and says right upfront: "A pointer is a variable that contains the address of another variable."

Way helpful

Pointers were in my opinion the hardest subject of C until I read your guide.

dirtycoder on denniskubes.com

What a? boss, I want this guy to lecture me :D

fr00tcrunchStarcraft on youtube.com

Nice tutorial!

Maybe it shows my age, but I am yet to understand why so many developers nowadays have such a hard time grasping pointers, regardless of the language being used to teach them.

pjmllp on news.ycombinator.com

Questions and answers

this helped alot thnx man ! ! now i know how to use pointers but i still don't know? why do we use em !!

xbadnerd18x on youtube.com

Arrays are not pointers; pointers are not arrays. This is perhaps the most common misconception about C, and a "Guide to C Pointers" should not propagate it.

_kst_ on news.ycombinator.com

Let me add …

Hi nice tutorial, one suggestion though is that many people learning c pointers are unsure some of the merits of why they should use them when they encounter these beginner tutorials

sulfide on denniskubes.com

They're post office box numbers.

In this analogy, the post office is all your RAM. The big place where my analogy breaks down a bit is that, in this little world, the post office will store things bigger than one box in multiple adjacent boxes, so to get anything into or out of the post office you have to specify which box you want them to start with and how many boxes they'll have to use.

derleth on news.ycombinator.com

y is the name of the integer. its just like algebra


y = 1

x= 2

x and y are both integers, the letters just represent numbers?

murder on youtube.com

Every time someone tries offering a simplified explanation of pointers, I've countered with the old Buddhist saying that, "The pointing finger is not the moon," followed by a brief foray into syntax and operators, e.g.,

moon* finger = &luna;

As often as not, enlightenment occurs.

rosser on news.ycombinator.com

What tutorial or book have you found most useful for C or C++?

For the latest IT news, analysis and how-tos, follow ITworld on Twitter, Facebook, and Google+.

Now read this:

Developer declares 'I am done with the Freemium Business Model'

Khan Academy offers JavaScript as their first computer language

Study says Facebook profile can predict job performance

ITWorld DealPost: The best in tech deals and discounts.
Shop Tech Products at Amazon