The meaning of the word generic

Discussion in 'C Programming' started by Albert, Dec 31, 2005.

  1. Albert

    Albert Guest

    Hello all, I've got several questions and I'm sure you'll find them
    easy to answer, but sadly I don't know the answers though:

    What do people mean by generic pointers
    Why is a pointer to void generic
    Why would someone need pointers to void?

    Thanks
    Albert, Dec 31, 2005
    #1
    1. Advertising

  2. Albert

    Thad Smith Guest

    Albert wrote:

    > What do people mean by generic pointers


    A pointer to an area of memory (if generic data pointer, rather than
    function pointer) that may be used for different purposes.

    > Why is a pointer to void generic


    Because it doesn't point to a specific type of data, but can be
    converted to a pointer to any data type.

    > Why would someone need pointers to void?


    One example is a pointer to the memory returned by malloc(). malloc()
    doesn't know or care what the memory will be used for. It returns a
    generic pointer that has type void*. Another example is the array
    argument passed to qsort().

    --
    Thad
    Thad Smith, Dec 31, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laura
    Replies:
    1
    Views:
    514
    Gunnar Hjalmarsson
    Jun 5, 2004
  2. Murat Tasan
    Replies:
    1
    Views:
    8,022
    Chaitanya
    Feb 3, 2009
  3. Replies:
    2
    Views:
    422
  4. Replies:
    4
    Views:
    736
  5. minlearn
    Replies:
    2
    Views:
    444
    red floyd
    Mar 13, 2009
Loading...

Share This Page