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 7589007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:03:54+00:00 2026-05-30T20:03:54+00:00

I have a networking framework that I am writing (Trying to implement reliable layer

  • 0

I have a networking framework that I am writing (Trying to implement reliable layer over UDP). I have this receive function that accepts a pointer to a packet object. The network framework then does a whole load of stuff to receive a packet, and sets the value of the packet pointer to this packet. But this happens a few functions deep. So what I am essentially wondering is, why this doesn’t something like this work for me: (very basic example to show you what i mean)

void Main()
{
   int* intPointer = NULL;
   SomeFunction(intPointer);
   //intPointer is still null?
}
void SomeFunction(int* outInt)
{
   SomeOtherFunction(outInt);
}

void SomeOtherFunction(int* outInt)
{
   outInt = new int(5);
}
  • 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-05-30T20:03:55+00:00Added an answer on May 30, 2026 at 8:03 pm

    SomeOtherFunction is passed a pointer by value, so the assignment only changes the local copy of the passed address.

    To make this work, pass the pointer by reference:

    void Main()
    {
       int* intPointer = NULL;
       SomeFunction(intPointer);
       //intPointer is still null?
    }
    void SomeFunction(int*& outInt)
    {
       SomeOtherFunction(outInt);
    }
    
    void SomeOtherFunction(int*& outInt)
    {
       outInt = new int(5);
    }
    

    Having said that, is there something wrong with using a return value?

    void Main()
    {
       int* intPointer = SomeFunction(intPointer);
       //intPointer is still null?
    }
    int* SomeFunction()
    {
       return SomeOtherFunction();
    }
    
    int* SomeOtherFunction()
    {
       return new int(5);
    }
    

    [ Update following comment. ]

    Well, if you have a return value indicating the status, presumably indicating whether or not the integer has been read, then what you really want is (using bool as a placeholder for your specific status):

    void Main()
    {
       int intPointer = 0;
       if (SomeFunction(intPointer) == true)
       {
           // read something
       }
       else
       {
           // failed to read.
       }
    }
    bool SomeFunction(int& outInt)
    {
       return SomeOtherFunction(outInt);
    }
    
    bool SomeOtherFunction(int& outInt)
    {
       outInt = 5;
       return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Entity Framework, I am writing a social networking app and trying to setup
I have heard that web-based chat clients tend to use networking frameworks such as
I'm working on a social networking system that will have comments coming from several
I'm currently trying to develop a message-oriented networking framework and I'm a bit stuck
I have a networking program setup that does a lot of what the nestat
I have a social networking website built upon the zend framework. My application also
I have an entity framework entity that i want to serialize as a json
I'm currently working on two social networking sites that have a lot in common,
I have a program that does some networking using Winsock, and one of our
I have been trying to get a simple networking test program to run with

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.