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
IgorC [24]
3 years ago
10

Complete the following function to create a deep-copy on the heap of the argv array. Set the result pointer to point to your arr

ay. The only library calls you may use are malloc and memcpy. You may not use strdup.
Computers and Technology
1 answer:
irga5000 [103]3 years ago
8 0

Answer:

Following are the code in the C programming Language.

//define function

void duplicate(char*argv, char**result) {

//set and initialize the variable to 0

int c = 0;

//set and initialize the char type pointer variable

char** t = argv;

//set the while loop

while(t){

//increment by 1

c++;

//increment by 1

t++;

}

//set malloc function in the pointer variable

result= malloc(sizeof(char)*(c+1));

//set the for loop

for(int i = 0; i < c; i++) {

//set malloc function in the pointer

(*result)[i] = malloc(strlen(argv[i])+1);

//copy the character from memory

memcpy(argv[i], (*result)[i], strlen(argv[i])+1) ;

}

//initialize null in the pointer

(*result)[i] = NULL;

}

Explanation:

In the following code, we define function "duplicate()" and pass two character type pointer arguments "*argv" and "**result" and inside the function.

  • Set an integer type variable "c" and initialize to 0.
  • Set character type pointer variable "t" and initialize the value of pointer variable "argv".
  • Set the while loop and increment in the variable "c" and "t" by 1.
  • Set the malloc function in the pointer variable "result".
  • Set the for loop to copy the character from the memory.
  • Finally, initialize the pointer variable "result" to NULL.
You might be interested in
What does it mean when it says this person is unavailable on messenger.
arsen [322]

Answer:

The user has a deactivated account 

Explanation:

or the user does not have the account anymore good luck and I hope you do well <3

4 0
2 years ago
For a typical program, the input is taken using _________ Command-line scanf Files All of the mentioned
vfiekz [6]

Answer:

D)All of above

Explanation:

This is the complete question

For a typical program, the input is taken using _________.

A)Files

B)Command-line

C)scanf

D)All of above

E)None of these

computer program could be regarded as a collection of instructions which can be executed using computer to carry out a specific task, and it is written by programmer ,Input in domain of computer could be explained as feeding some data into a program. This input could be in the form of a file as well as command line, with the help of programming set of built-in functions that will help in reading the given input as well as feeding it to the program base on requirement. The scanf do reads the input from the standard input stream( stdin and scans) which is been input based on provided format. It should be noted that For a typical program, the input is taken using Files, Command-line and scanf.

7 0
3 years ago
Need answer ASAP. I’ll mark brainliest if correct
garik1379 [7]

Answer:

I am pretty sure for the first option the answer is tasks, and for the second option, it is logical.

Explanation:

"tasks to be performed in a logical manner" sounds right to me.

6 0
3 years ago
According to popular science Web sites, the scientific process of digital forensics normally starts with a(n) ________.
neonofarm [45]

Answer:

a hypothesis that forms into a question.

Explanation:

5 0
3 years ago
Sierra owns a small business and handles many responsibilities, from logistics to marketing. She's seen a lot of success with Go
Elenna [48]

Answer:

A Smart Display campaign

Explanation:

She can go for Smart Display Campaign.

4 0
4 years ago
Other questions:
  • Write a program that estimates the approximate number of times the user’s heart has beat in his/her lifetime using an average he
    12·1 answer
  • Write a program whose input is two integers and whose output is the two integers swapped. Place the values in an array, where x
    12·1 answer
  • Which license enables anyone on the network to install and use the software?
    14·1 answer
  • Dr. Robbins wants to know if there are different opinions regarding the value of public school education between Native American
    11·1 answer
  • A manufacturing company inspects all products before selling them. Less than 1% are defective and do not pass inspection. You ar
    9·1 answer
  • What are the diffrent types of contract
    9·1 answer
  • To protect yourself from the risk of product failure, what strategy could you use?
    15·1 answer
  • Program Convert Measurements:
    15·1 answer
  • PLEASE HELP WILL GIVE BRAINLIEST!!!’
    15·1 answer
  • What is your idea for creating a new and fresh Gaming experience around viewing occasions for Mike's?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!