Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8783383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:49:16+00:00 2026-06-13T20:49:16+00:00

I have a void** p2 variable created like for example int x = 10;

  • 0

I have a void** p2 variable created like for example

int x = 10;
void* p = &x;
void** p2 = &p;

This is created in a function. How can I, using parameters or return value, pass this p2 in a way that p2 and * p2 both keep their exact value. I did not succeed in finding any solution. Please give me a short example, anything would do.

Maybe some details could help:

class ShmItem
{
public:
    void* start;
    void** vtable;
};

this class is global, its part of a global vector.
now in my function.

item.vtable = &item.start;
shm->address = item.vtable;

where item start holds the return value of mmap.

shm is an parameter object where address is of type void**.

Now when I return to the caller voila the value of item.start changes (in the shm->address)…

Sorry, I have found the bug, which has nothing to do with pointer. Can I delete this thread? Because the question makes no sense any more. (Although Carlos’ way of passing double pointers across funcion calls is a good idea which helped me, so I marked it as answered).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:49:17+00:00Added an answer on June 13, 2026 at 8:49 pm

    I’m assuming you’re using C right?
    So, I think you need to do two things.
    First, declare you double pointer variable outside the function so it is in scope after the function returns.
    Second, declare your function such that it receives and returns a void ** param that will hold the value you want, like so:

    void **myfunc (void **p2) {
        int x = 10;
        void* p = &x;
        p2 = &p;  // notice var declaration is gone
        ...
        return p2;
    }
    void ** p2;
    p2 = myfunc(p2);
    

    You could also declare myfunc to return void and call myfunc with p2 without the assignment construct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have: void add_all_msgs(std::deque<Message>::iterator &iter); How can I make that function generic, so it
I have this function: void func(int a, int b, char s, FILE *fp, int
I have this function to be created, but the variable view_size is being treated
I have this function: void ToUpper(char * S) { while (*S!=0) { *S=(*S >=
This is the scenario; // I have created a buffer void *buffer = operator
I have a C header file like this: #ifndef RENDERER_H #define RENDERER_H static int
Let's suppose I have a struct like this: struct my_struct { int a; int
I have a private variable in my class: BOOL isEnabled; and a method: -(void)
I have a void pointer returned by dlsym(), I want to call the function
I have: typedef void (*RespExtractor) (const cv::Mat & image, cv::Mat & resp); virtual void

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.