Thread: Quick help with pointers

  1. #1
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    Quick help with pointers

    Ok, I think I understand pointers. Definitely the basic stuff about them. But as I understand they are very important in c++ so I want to have a very firm grasp on them. Could someone please give me a little project/assignment/whatever that has a main focus on pointers. I mean an assignment that, if I am able to do it, means I understand pointers well enough to move on. Thanks.

  2. #2
    Darrok
    Guest
    design a program that goes through each memory location and sets its value to 0

    you'll better learn to use pointers and really mess some stuff up at the same time!

  3. #3
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    come on

    seriously come on please

  4. #4
    Darrok
    Guest
    but seriously, maybe design a program that allows you to move forward or backward on an 800 byte memory space and display the value or add/subtract 1 from it

    and use pointers, not just an array, that's cheating

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    write your own stack, queue or list object.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  6. #6
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    what

    what do you mean?

  7. #7
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    = )

    Pointers, while very important, are not as infinitely important as you think. It's better to just learn them enough to understand the concept and then continue on. While this may sound stupid, once you get to learning things such as queues, stacks, binary trees and the like, you'll probably have a good grasp of pointers.

    Random blit of information that will more than likely not be very useful: The -> is the operator used for pointers to structures.

  8. #8
    Unregistered
    Guest
    So you're an expert on pointers.

    Exercises:

    1) define a function pointer for:
    char* fn1(int* nm) {}

    2) this function can be called with 1 or more int-parametres:
    long fn2(int nm, ...);

    Say its return value is the sum of the actual parametres,
    no matter how many there are;
    try to write the body of fn2(). (... Tip: you'll need stdarg.h)

    Too easy. I'll come up with some devastating exercises
    tomorrow.

  9. #9
    Registered User
    Join Date
    Dec 2001
    Posts
    60

    some more exercise

    Originally posted by Unregistered
    So you're an expert on pointers.

    Exercises:

    1) define a function pointer for:
    char* fn1(int* nm) {}

    2) this function can be called with 1 or more int-parametres:
    long fn2(int nm, ...);

    Say its return value is the sum of the actual parametres,
    no matter how many there are;
    try to write the body of fn2(). (... Tip: you'll need stdarg.h)

    Too easy. I'll come up with some devastating exercises
    tomorrow.
    3) char **a;
    a=new char*[12];
    Exercise: Try to copy the strings "January" ... "December"
    to the heap and use cout to show them. (Tip: strcpy ...)
    (Note that only 4 Bytes are wasted on the stack for
    the pointer a)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 04:23 AM
  2. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 06:58 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. moving pointers to pointers
    By Benzakhar in forum C++ Programming
    Replies: 9
    Last Post: 12-27-2003, 08:30 AM
  5. Questions on basic Quick Sort
    By Weng in forum C++ Programming
    Replies: 4
    Last Post: 12-16-2003, 10:06 AM