Good pointer learning tool?

This is a discussion on Good pointer learning tool? within the C Programming forums, part of the General Programming Boards category; Hey, I don't have any specific coding question, but I am having a lot of trouble with pointers in my ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    14

    Good pointer learning tool?

    Hey, I don't have any specific coding question, but I am having a lot of trouble with pointers in my class and was wondering if anyone knows of a good tool or website to help learn. I've been rummaging around other websites but it isn't really "clicking" for me. I feel like I am falling behind but my professor's office hours are during another class. Any hints or tips pertaining to pointers would be more than welcome as well.

    I do know that pointers' contents are just addresses of other variables, but I'm having a lot of trouble knowing how and when to use them as parameters with their symbols (*, &).

    Thanks in advance!
    Last edited by Devolution; 03-11-2009 at 02:49 PM.

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Linked lists (if you can). Find a linked list tutorial and try and write a basic program to add, remove, and show all nodes.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,756
    A small guide:
    int x = 10;
    int* p = &x;
    *p = 20;
    After this, x is 20, and *p is 20.
    Before, x is 10.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    26
    the best way to understand pointers is to study a little bit of assembly language

  5. #5
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Quote Originally Posted by baccardi View Post
    the best way to understand pointers is to study a little bit of assembly language
    makes no sence for me
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  6. #6
    Registered User
    Join Date
    Jan 2009
    Posts
    26
    so i guess you haven't studied it, because programming with assembly involves computer architecture knowledge which is very good in understanding how really pointers work

  7. #7
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Quote Originally Posted by baccardi View Post
    so i guess you haven't studied it, because programming with assembly involves computer architecture knowledge which is very good in understanding how really pointers work
    you guessed wrong
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  8. #8
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > so i guess you haven't studied it, because programming with assembly involves computer architecture knowledge which is very good in understanding how really pointers work
    I disagree. Looking at how one implementation works is by no means a good way to learn how they work overall. Not to mention there is usually no concept of "pointers" at such a low-level.

    That's like learning how to drive by looking at how the steering column in your car works.
    Last edited by zacs7; 03-11-2009 at 04:10 PM.

  9. #9
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    in c '&' is the address of operator which gives the address where the variable in memory is stored.'*' is the value at address operator.it means if you use '*' and '&' with a variable it will give you the variable's value.
    for eg.
    Code:
    int i=10;
    printf("%u %d",&i,*(&i));
    this will output the address and the value of i(which is 10).
    Now this means that if you want to have access to the address of the variable you can use these operators.and once you have access to any variable's address you can change it to other value or can do some operations upon it.thus if you want to change the value of a variable or do some advanced operations you need to pass the address of the variable.

  10. #10
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,738
    Quote Originally Posted by Elysia View Post
    A small guide:
    int x = 10;
    int* p = &x;
    *p = 20;
    After this, x is 20, and *p is 20.
    Before, x is 10.
    int * q;
    q = p;
    This is pointer assignment for pointers with the same level of indirection, since we're copying the value of p (some address), not p's address.
    ++(*q);
    *q++;
    Know the syntax for your increments and decrements.

  11. #11
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,883
    Quote Originally Posted by whiteflag
    Know the syntax for your increments and decrements.
    Building on whiteflag's examples, find out the difference (if any) between ++*q, ++(*q), *q++ and (*q)++.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  12. #12
    Registered User
    Join Date
    Jul 2008
    Posts
    11
    This is really cool, when you can follow this guy you will be the pointer master . I followed a lesson or 4 or so, and found it really "clearing up the mist". If i find some more time i'm going to watch the whole "show"

    http://www.youtube.com/watch?v=Ps8jO...eature=related

    B.t.w. i think i found the link on this forum, somewhere...

  13. #13
    Complete Beginner
    Join Date
    Feb 2009
    Posts
    312
    I have to see some formal stuff in order to understand things, and the following helped me a lot to understand pointers:

    A variable is a 4-tuple consisting of name, size, address and value.
    A pointer is a variable whose value is the address of another variable.

    For C, this is almost true. On the other hand, you don't need to fully grasp the concept of pointers right at the beginning. Read through the pointer chapter of whatever book you are using to learn C, but don't try to understand everything. When you're actually dealing with pointers (writing a linked list is the common example), stick to syntactical rules. When you're used to the syntax, read the chapter again.

    Pointers are so difficult because the first time you hear about them, you probably don't have the slightest clue about their usefulness. First find out why they are useful and how to use them syntactically, then try to understand them.

    Greets,
    Philip
    All things begin as source code.
    Source code begins with an empty file.
    -- Tao Te Chip

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. scope of a pointer?
    By Syneris in forum C++ Programming
    Replies: 6
    Last Post: 12-29-2005, 08:40 PM
  2. Question About Pointer To Pointer
    By BlitzPackage in forum C++ Programming
    Replies: 2
    Last Post: 09-19-2005, 10:19 PM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. Learning DirectX 6.1. Still Good...?
    By Cheeze-It in forum Game Programming
    Replies: 5
    Last Post: 05-21-2002, 04:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21