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]
3 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]3 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 is an optical storage device?
svp [43]
 cartridges, erasableoptical<span> cartridges, and Removable Mass </span><span>Storage</span>
4 0
4 years ago
Read 2 more answers
In electrical work, resistance is often represented by thea. Greek symbol O.
Elanso [62]

Resistance is often represented by Ω, (pronounced Ohm). The symbol itself is actually omega though, which is the Greek symbol for O.

So your answer is a.

3 0
3 years ago
A(n)_______ is malware that arrives in a trojan, disguised as legitimate software, and then sets up a(n) that provides unauthori
soldi70 [24.7K]

The RAT-Remote Access Trojan is a kind of malware that allows unauthorized access to your devices.

Explanation:

The Remote Access Trojan is a kind of malware that is similar to legitimate software programs. It allows unauthorized users to control your computer without your permission. Hackers will attach the RAT with documents like email, any software’s or games. It is difficult to identify RAT than any other viruses or malware. Antivirus software can able to prevent attacks from RAT like malware and act as extra security to your devices.

4 0
3 years ago
What tool can help discover and report computer errors when you first turn on a computer and before the operating system is laun
Vlada [557]

Answer:

a post diagnostic

Explanation:

4 0
3 years ago
Read 2 more answers
i give up on understanding and trying to pass science. ive now started clicking random letters as the choices. i actually got a
Rzqust [24]
Um okay, that's not a question so why even post it.
7 0
3 years ago
Other questions:
  • Grace is the sub-editor in a business firm. which feature of a word processing program would she use to make her changes visible
    14·1 answer
  • Write a program with total change amount as an integer input that outputs the change using the fewest coins, one coin type per l
    13·1 answer
  • What are the three major functions of a game engine?
    15·1 answer
  • Pass only _____ at a time.
    13·2 answers
  • File Sales.java contains a Java program that prompts for and reads in the sales for each of 5 salespeople in a company. It then
    8·1 answer
  • What is a set of illustrations displayed in a specific sequence to pre-visualize what your mobile app looks like and how it work
    5·1 answer
  • ????????????????????????????????
    5·1 answer
  • Identify one technology tool used for work​
    7·1 answer
  • A character that <br>is raised and smaller above the baseline is called​
    6·1 answer
  • What is the current situation of drone technology in emergency rescue and recovery
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!