A few questions on pointers

This is a discussion on A few questions on pointers within the C Programming forums, part of the General Programming Boards category; Hi guys, I need some help. 1) What exactly does this mean and how do I use this definition: Code: ...

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    15

    A few questions on pointers

    Hi guys,

    I need some help.

    1) What exactly does this mean and how do I use this definition:
    Code:
    typedef int (*Tf2)(int [], int);
    2) How can I get the value of one element from this 2D array, inside the function?
    For example, if it was declared as int v[][], I would do v[5][6]. Can I do the same with pointers?
    Code:
    int function(int **v)
    Thank you.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,750
    1. It's a typedef for a function pointer.

    Eg.
    Code:
    int foo ( int array[], int size ) {
    }
    
    Tf2 myfunc = foo;
    
    result = myfunc( array, len );  // calls foo
    > For example, if it was declared as int v[][], I would do v[5][6]. Can I do the same with pointers?
    No, you cannot pass an array declared [][] to a pointer expecting **
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. malloc problem
    By Tool in forum C Programming
    Replies: 23
    Last Post: 03-12-2010, 10:54 AM
  2. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  3. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 06:58 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. moving pointers to pointers
    By Benzakhar in forum C++ Programming
    Replies: 9
    Last Post: 12-27-2003, 08:30 AM

Tags for this Thread


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