1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Harrizon [31]
2 years ago
7

Write two statements that each use malloc to allocate an int location for each pointer. Sample output for given program:

Computers and Technology
1 answer:
Mekhanik [1.2K]2 years ago
7 0

Answer:

#include <stdio.h>

#include <stdlib.h>

int main(void) {

   int* numPtr1 = NULL;

   int* numPtr2 = NULL;

   /* Your solution goes here */

   numPtr1 = (int *) malloc(10);

   numPtr2 = (int *) malloc(20);

   *numPtr1 = 44;

   *numPtr2 = 99;

   printf("numPtr1 = %d, numPtr2 = %d\n", *numPtr1, *numPtr2);

   free(numPtr1);

   free(numPtr2);

   return 0;

}

Explanation:

The C library malloc function is used to assign memory locations (in bytes) to variables. It accepts the size parameter and returns a pointer to the specified variable location.

The two malloc statements above assign two memory locations 10 and 20 to the numPtr1 and numPtr2 integer variables respectively.

You might be interested in
Write a recursive method in pseudo code that returns the number of 1's in the binary representation of n. use the fact that this
Deffense [45]
Int count(int num)

if   num==0   return  0;
return   (n&1)+count (n/2)


4 0
3 years ago
How can you have a safe browser experience
goldfiish [28.3K]

Most likely the answer is to delete cookies, as it cuts down on the amount of tracking sites can do to you.

6 0
3 years ago
Which organization developed a network called CSNET to provide a network free to all American research and educational instituti
Citrus2011 [14]
<span>The National Science Foundation (NSF) is the organization which </span><span>developed a network called CSNET to provide a network free to all American research and educational institutions. It is an agency in the government of the United States that is responsible for research and development in the field of science and engineering. </span>
7 0
3 years ago
I can’t unblock brainly from my computer, I think a robot has the same IP address .
prisoha [69]
They won’t let it be on your computer, knowing it well give you answers
6 0
3 years ago
Read 2 more answers
Which social networking site became a gaming platform after 2009
PtichkaEL [24]

Answer:

Should be Hi5

have good day

3 0
3 years ago
Other questions:
  • Consider this scenario: A major government agency experiences a data breach. As a result, more than 100,000 personal records are
    7·2 answers
  • 10 10 105 Each process is assigned a numerical priority, with a higher number indicating a higher relative priority. In addition
    8·1 answer
  • Ray has to type an invoice using the QWERTY keyboard. Along with letters and numbers, he also has to insert the dollar sign. Whi
    13·1 answer
  • In 2009, __________ accounted for 1,772 total fatalities. A. passengers riding with impaired drivers B. children hit by backing
    14·2 answers
  • What are the two most popular applications of theInternet?
    7·1 answer
  • What does it mean if my ninja blender power light is blinking?
    13·2 answers
  • PLEASE HURRY!!!!<br> Look at the image below
    8·1 answer
  • An Excel file that contains one or more worksheets
    15·1 answer
  • Is Invader Zim gonna come back?
    7·1 answer
  • What is the accurate description
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!