Thread: Dereferencing double pointers

  1. #1
    Registered User
    Join Date
    Sep 2016
    Posts
    21

    Dereferencing double pointers

    Hello!

    I have a variable that points to a character, i.e.
    Code:
    char* ptr = &characterInArray;
    Now I want to send the adress of the ptr-variable into a function so I can modify where it points, but my problem is that I don't know how I am supposed to check the adress before what ptr points to. I have tried this for example:
    Code:
    if (**(ptr - 1) == token)
        //Do something;
    How should I proceed?

    EDIT: To clearify, if ptr points to a character in an array I want to check the previous value in the array by using the pointer.
    Last edited by Kirderf; 12-29-2016 at 09:01 AM.

  2. #2
    Registered User
    Join Date
    Sep 2016
    Posts
    21
    Funny enough I solved it within a minute after posting this thread. The way I am supposed to look at it is like declaring a variable. To check the preceding value I have to do this:
    Code:
    if (*(*ptr - 1) == token)
        //Do something

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help dereferencing pointers
    By chey15 in forum C++ Programming
    Replies: 15
    Last Post: 02-28-2014, 07:52 AM
  2. dereferencing void pointers in my realloc
    By mattholm in forum C Programming
    Replies: 1
    Last Post: 12-11-2011, 01:14 PM
  3. Pointers & dereferencing confusion
    By LanguidLegend in forum C Programming
    Replies: 9
    Last Post: 11-18-2011, 11:31 AM
  4. Replies: 6
    Last Post: 09-30-2010, 12:24 AM
  5. Dereferencing Pointers help
    By Rune Hunter in forum C++ Programming
    Replies: 10
    Last Post: 07-14-2007, 06:43 PM

Tags for this Thread