Thread: Pointers

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    8

    Pointers

    I have the following code:

    Function1()
    {

    PUINT16 a;

    a = (PUINT16)info->b;

    Function1(a);
    }

    Fuction2(PUINT16 p)
    {
    INT c = p[0] & 0xFF;
    ....
    }

    Whats does p[0] refer to?

  2. #2
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    603
    Hope this is right.....

    The first member of the array p?
    Visit entropysink.com - It's what your PC is made for!

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Hope this is right.....
    It is

    -Prelude
    My best code is written with the delete key.

  4. #4
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    603
    HEY!!!! I'm getting the hang of this!
    Visit entropysink.com - It's what your PC is made for!

  5. #5
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    This code doesn't look right:

    Code:
    Function1() 
    {
        PUINT16 a; 
        a = (PUINT16)info->b; 
        Function1(a); 
    }
    First off, the function calls itself recursively passing a parameter but it doesn't look like the function accepts a parameter as you have it defined.

    Secondly, there is no condition that will cause this function to halt the recursion. It will keep calling itself until it runs out of stack space, crashing the program.

    Is this just supposed to be a sample of code to illustrate the problem you are having? If not then it needs fixing.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. MergeSort with array of pointers
    By lionheart in forum C Programming
    Replies: 18
    Last Post: 08-01-2008, 10:23 AM
  2. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 AM
  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. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 01:18 PM