6 Replies - 560 Views - Last Post: 25 December 2009 - 12:29 PM Rate Topic: -----

#1 manish muvel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 23-December 09

how can I learn about pointers?

Posted 23 December 2009 - 10:54 PM

i don't understand pointers ????????????????????????
Is This A Good Question/Topic? 0
  • +

Replies To: how can I learn about pointers?

#2 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: how can I learn about pointers?

Posted 23 December 2009 - 11:04 PM

Read stuff
(Like this)
http://www.dreaminco...topic118308.htm

Apply what you read

Repeat.
Was This Post Helpful? 0
  • +
  • -

#3 Spencer William  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 33
  • Joined: 14-June 09

Re: how can I learn about pointers?

Posted 23 December 2009 - 11:17 PM

Definitely read up on them, but do you have any specific question about them? As a very rough intro to pointers, think of them like this. They point to an object in memory. As opposed to actually storing the data, they store a copy of the address of the data. It's like opening your mailbox and instead of finding your package you found a note that told you where to get it. That being said, here's how to define them.

int * a; this instantiates a pointer to an int

so...

cout << a; would produce something like this ffa4ad56. basically a hex number

however, when you want to access the actual data being pointed to, you must "de-reference" the pointer.

like this.

cout << *a; that would produce the actual value of the int such as "4"

If you want to assign something be careful. Remember to de-reference or else you will change the value of the address in memory and bad things will happen. :)

so again if you want to change the value, do this.

*a = 10 and so on.

Hope this gets you started!

:)
Was This Post Helpful? 0
  • +
  • -

#4 Neeskens  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-September 09

Re: how can I learn about pointers?

Posted 24 December 2009 - 01:30 PM

Those links helped me a lot when I was learning pointers in C.

Pointer Basics - http://cslibrary.stanford.edu/106/
Pointer and Memory - http://cslibrary.stanford.edu/102/

View Postjanotte, on 23 Dec, 2009 - 10:04 PM, said:

Read stuff
(Like this)
http://www.dreaminco...topic118308.htm

Apply what you read

Repeat.


Arenīt function pointers a little too much for a newbie.?

This post has been edited by Neeskens: 24 December 2009 - 01:31 PM

Was This Post Helpful? 0
  • +
  • -

#5 Bench  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 855
  • View blog
  • Posts: 2,338
  • Joined: 20-August 07

Re: how can I learn about pointers?

Posted 24 December 2009 - 04:42 PM

A few more excellent pointer links:
http://www.daweidesi...in/pointers.php
http://www.eternally...t_pointers.aspx
http://www.augustcou...torial/ptr.html
http://www.c-faq.com/ptrs/index.html
Was This Post Helpful? 0
  • +
  • -

#6 ice-t  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 104
  • Joined: 26-May 09

Re: how can I learn about pointers?

Posted 25 December 2009 - 10:10 AM

u can read a lot but try to code and practice what u read,eventually u`ll get it.
Was This Post Helpful? 0
  • +
  • -

#7 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 614
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: how can I learn about pointers?

Posted 25 December 2009 - 12:29 PM

Basically, its very simple. Pointers simply provide a way to directly access the memory of a computer. For example, lets say you want to change the value of a variable that is stored in memory. One way of doing that would be pointers.

For example...

int *pointer = NULL;

int num = 10;

pointer = &num;	  // Like saying , "Pointer = the address of num"

*pointer = 100;	  // Like saying, go to the address stored in pointer and change the value at that address to 100

now num = 100



You can add your own address to the pointer although, it can be dangarous...for example

inr *pointer = (int*)100;

pointer = 10;



That would change the value stored at address 100 to 10....
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1