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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:18:48+00:00 2026-06-02T10:18:48+00:00

I send a pointer to an array of char* to a function (args). In

  • 0

I send a pointer to an array of char* to a function (args). In that function I set the value to the first two postions in the array to malloc’d strings. When I return to the orignal calling function where the array itself was malloc’d, the last position of the array gives me a “Cannot access memory at address 0x0”. Am I doing somthing wrong in malloc/realloc/ or storing the values?

Calling Function:

int bufspace = 0; /* bytes in table */

    ...

args = emalloc(BUFSIZ); /* initialize array */
bufspace = BUFSIZ;     //size=8192
spots = BUFSIZ / sizeof(char *);

while (*cp != '\0') //While not at the end
    cp = read_segment(cp, &len, &indollarsign, &argnum, start, &args, &prev_char_escape);
    start = cp;
    len = 0;

    if (argnum + 1 >= spots) {
        args = erealloc(args, bufspace + BUFSIZ);
        bufspace += BUFSIZ;
        spots += (BUFSIZ / sizeof(char *));
        }
    }

Called Function (read_segment) – First called to store at position 0 then at position 1:

*args[*argnum] = newstr(start, *len); //Generate the string through malloc

At this line, I have strings in these positions: *args[0] and *args[1]

But as soon as I return to the calling function
args[0] has a string but args[1] shows a “Cannot access memory at address 0x0”

  • 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-02T10:18:49+00:00Added an answer on June 2, 2026 at 10:18 am

    *args[*argnum] dereferences the pointer at args[*argnum]. I think you meant

    (*args)[*argnum] = newstr(start, *len);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Send Iqueryable to a function that is below void Method<T>(ref IQueryable<T> qu) {
I need to send a pointer to a character array to one of my
I have a function which takes an int * and modifies the array that
I have a pointer in an objective-C class that I need to send messages
I have an object with a char Array; where the first 5 bytes(char in
I send out a newsletter email containing URLs to a https website that then
i send ajax requests with jquery, and i have a function: $('input').ajaxSuccess(function(e, xhr, settings)
I send data between sockets in a C-application. I first bind the 'receiver' to
Is it possible to send a pointer to an object via Mach IPC by
I have an iPhone app with an array of objects that I want to

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.