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
Electronic ledger that tracks mathematical data
lesya692 [45]
<span>These kinds of systems are usually installed in the cockpits of aircrafts. It is an electronic computer-controlled display system. It is made up of several kinds of systems constituting the whole.  The purpose of such a kind of display is to increase and widen the field of vision and decrease any kind of visual disturbances from the surroundings. The Flight Data Display another constituent of the system constantly updates the pilots with the status of and data related to the flight. This also includes information about the aircraft itself and navigation information too.</span>
7 0
3 years ago
Which of the following is among the ComScore Ad Metrix Reports?
IceJOKER [234]
I think it is d but not exactly sure
6 0
2 years ago
What is the point of having bullets points in a text box
Ludmilka [50]
You should have bullets in a text box in case you have a list of stuff. For example:

Computer Parts

.Tower

.Monitor

. Mouse

.Printer


3 0
3 years ago
What is a document?
kotykmax [81]

Answer:

answer is Set of information gathered together

4 0
2 years ago
Read 2 more answers
Which tcp/udp port does the dns service use to communicate?
denis23 [38]
Port 53

Man sometimes the answer minimum of 20 to explain is a bit unnecessary.
It's port 53 what else do you need to know?
7 0
3 years ago
Other questions:
  • Don is the superintendent of the county school system. What task might Don
    8·1 answer
  • 1. Engineers should not consult with experts if they do not know much about a problem.
    12·1 answer
  • Topological sort requires only a tiny addition to the DFS algorithms. Exactly one of the following data structures is required t
    9·1 answer
  • 6. While using the HTS, ________________ will help maintain a safe driving environment despite high speeds and a large number of
    12·1 answer
  • What is the main reason that IT managers believe the future IT career model will be diamond-shaped, with few entry-level IT jobs
    7·1 answer
  • Business cards are generally designed so that this item stands out the most.
    8·1 answer
  • PLEASE HELP!
    14·2 answers
  • Which statement best describes desktop publishing?
    10·1 answer
  • When you check your hard drive to see how much space is available, you are checking your
    15·1 answer
  • The output of a computer can be seen on ( monitor, keyboard or mouse )​
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!