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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:28:20+00:00 2026-06-17T00:28:20+00:00

i have a question… lets say i have the following part of code :

  • 0

i have a question… lets say i have the following part of code :

int *a,*a1,*a2;
for (i=1; i<=2; i++) {
    a=malloc(sizeof(int));
    if (i==1) a1=a;
    else if (i==2) a2=a;
}
*a1=5;
*a2=4;

so my question is
if i use printf to print a1 and a2 the variable a1 is gonna to have the value 5 and the a2 the value 4 ? so if i use malloc to allocate memory and a points in that memory space and use again malloc to allocate memory then a points to a different part of memory but the first one part of memory still exist ? or if i use malloc with a again it will erase the first part of memory and it will write a new part of memory

  • 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-17T00:28:21+00:00Added an answer on June 17, 2026 at 12:28 am

    Each call to malloc returns a pointer to different memory, until you call free to release that memory.

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

Sidebar

Related Questions

i have question from programming pearls problem is following show how to use Lomuto's
I have question,this is the following code. <form action= method=post id=search> <div class=row collapse>
I have question about throw. How will the throw work in the following code?
I have question please refer the following code to understand the question. (I removed
I have question i.e how can i select a previous div CODE:- if($i >
I have question regarding the use of function parameters. In the past I have
i have question how write program which calculates following procedures http://en.wikipedia.org/wiki/Tetration i have exponential
I have question about my code which does the Hoare Partition Method. Here is
I have Question model , which has attributes status , code , type .
I have question: when I to use <%= ConfigurationManager.AppSettings[xxx] %> and <%$ AppSettings: xxx

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.