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

  • Home
  • SEARCH
  • 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 8917837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:35:32+00:00 2026-06-15T05:35:32+00:00

I am attempting to pass a pointer to array in a function and return

  • 0

I am attempting to pass a pointer to array in a function and return it back. The problem is that after correct initializing the function returns a NULL-pointer. Can anyone tell me, what is the issue with my logic?

Here is my function, where array is declared:

void main()
{
     int errCode;
     float *pol1, *pol2;
     pol1 = pol2 = NULL;
     errCode = inputPol("A", pol1);
     if (errCode != 0)
     { 
         return;
     }

     // using pol1 array

     c = getchar();
}

And here is the function with initialization:

int inputPol(char* c, float *pol)
{
    pol= (float *) calloc(13, sizeof( float ) );
    while( TRUE )
    {
         // While smth happens
         pol[i] = 42;
         i++;
    };
}
  • 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-15T05:35:33+00:00Added an answer on June 15, 2026 at 5:35 am

    You need to pass the address of pol1, so main knows where the allocated memory is:

    void main()
    {
        int errCode;
        float *pol1, *pol2;
        pol1 = pol2 = NULL;
        errCode = inputPol("A", &pol1);
        if (errCode != 0)
        { 
             return;
        }
    
        // using pol1 array
    
        c = getchar();
    }
    
    int inputPol(char* c, float **pol)
    {
        *pol= (float *) calloc(13, sizeof( float ) );
        while( TRUE )
        {
             // While smth happens
             (*pol)[i] = 42;
             i++;
        };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to pass a pointer to a function that is defined in one
i have been attempting to pass an object into a function that belongs to
I am attempting to pass back a Node type from this function, but I
Language: C++, MFC Problem: I am attempting to pass a function some pointers to
I am attempting to pass back an object with a property that is a
Im attempting to pass an array that is created in one class into another
I want to have a function pointer that can take various types of parameters.
I am attempting to pass a managed function pointer void (*)(void *) to my
I am attempting to pass a bash environment variable back into my fabric function
Django has a decorator function called @transaction.commit_manually . I am attempting to pass a

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.