Ad
  • Custom User Avatar

    @caelumable, temp is merely a pointer. It points into same chunk of calloced memory that final points at.

    That memory will be freed in the test code.

    EDIT: My mistake, the test code doesn't free the returned memory at all. I guess the author wrote code in this way to allow solutions this return references to static variables.

  • Custom User Avatar

    eum....may I ask when dose the temp be destroyed? and why ? the temp didn't declear in the domain of the for loop, why it destroyed after the for loop?

  • Custom User Avatar

    temp pointer is incremented in a for loop, if you want to return it you should decrement it same amount of times because, as @status stated, it points to nothing after for loop.

  • Custom User Avatar

    Because temp pointer point to nothing now.

  • Custom User Avatar

    Because temp pointer point to nothing now.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution