Thread: int **ptr

  1. #1
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953

    int **ptr

    What is int **ptr? and how can we use it?
    none...

  2. #2
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Thanks for reply, but for example here:
    Code:
    void printStr(char **str1)
    {
        printf("String2 is %s\n", *str1);
        return;
    }
    Why did you use char **str1, why didn't we just use char *str1?
    none...

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>Why did you use char **str1, why didn't we just use char *str1?
    No reason to do so, *str1 would have done the job.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Registered User
    Join Date
    Dec 2002
    Posts
    5

    Exampe for int **ptr

    int **ptr points to a pointer variable, i.e; it contains the address of a pointer variable of type integer.

    #include <iostream.h>

    int add( int **, int **);

    int main (void)
    {
    int x = 4;
    int y = 9;

    int *ptrx = &x;
    int *ptry = &y;

    int result = 0;
    result = add(&ptrx, &ptry);

    cout << result << endl;

    return 0;

    }


    int add( int **ptr_ptrx, int **ptr_ptry)
    {

    //cout << **ptr_ptrx << endl;
    //cout << **ptr_ptry << endl;
    return ( **ptr_ptrx + **ptr_ptry);
    }

  5. #5
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Thanks alot, Salem, Hammer, and nasir...
    Now I know how to use it, and Hammer your reply helped alot, I was confused, that we used int **ptr, and now I get it.
    none...

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    @nasir_sidd: code tags please
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory leak
    By aruna1 in forum C++ Programming
    Replies: 3
    Last Post: 08-17-2008, 10:28 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM
  4. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM
  5. easy if you know how to use functions...
    By Unregistered in forum C Programming
    Replies: 7
    Last Post: 01-31-2002, 07:34 AM