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
What does every formula in microsofte excel spreadsheet start with??
Sedbober [7]
Equal sign (=) 
hope so !!!

5 0
3 years ago
Read 2 more answers
Rocks created from compaction and cementation of sediments are called:
Effectus [21]

Answer:

Sedimentary Rocks

Explanation:

Sedimentary rocks are essentially the Frankenstein monsters of the rock world. They're made up of pieces of igneous and metamorphic rocks, sand, clay, and other sedimentary rocks.

4 0
2 years ago
Jim has just purchased two new SCSI hard disk drives and a controller card for them. He properly installs the hardware in his ma
yawa3891 [41]

Answer:

  • Create partitions on each hard disk drives.
  • Mount the partition created on each hard drive so they are accessible by the the operating system.
  • Format the partitions created with a filesystem recognized by Linux.

Explanation:

Having purchased the two new SCSI hard disk drives with the controller cards for each and installed them properly, before using them for data storage and retrieval he must first use the fdisk command to create one or more partitions on each of the hard disk drives then mount any partitions created on the two hard drives so that they are accessible by the operating system before then proceeding to format any partitions created with a valid filesystem recognized by Linux.

4 0
3 years ago
Of the choice below,access to with tab will start a power point presentation
kow [346]

the menu and the toolbars
4 0
3 years ago
When you enforce restrictions, what must you do immediately?
sweet [91]
The answer is A create a password
4 0
3 years ago
Read 2 more answers
Other questions:
  • 2. Write the binary representation of number 1037.379 in IEEE 754 standard in single precision. Express the result in binary, oc
    7·1 answer
  • Unix has experimented with several security programs. a user can attach a watchdog program to a file that grants or denies acces
    13·1 answer
  • Word offers a multitude of picture formatting options that allow you to flip, rotate, and make many other adjustments to inserte
    15·1 answer
  • It is a function that ends the connection to the database.
    9·2 answers
  • Write pseudocode instructions to carry out each of the following computational operations:1. Determine the area of a triangle gi
    12·1 answer
  • You want to purchase a new hard drive for your workstation and are deciding between an HDD and an SDD. Which of the following is
    13·1 answer
  • Select the best answer to the following question.
    5·1 answer
  • Write steps for converting decimal to binary numbers?
    13·1 answer
  • (10 LC)
    5·1 answer
  • What is the greatest number of bits you could borrow from the host portion of a class B subnet mask and still have at least 130
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!