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
earnstyle [38]
3 years ago
3

Use strlen(userStr) to allocate exactly enough memory for newStr to hold the string in userStr (Hint: do NOT just allocate a siz

e of 100 chars).
#include
#include
#include
int main(void) {
char userStr[100] = "";
char* newStr = NULL;
strcpy(userStr, "Hello friend!");
/* Your solution goes here */
strcpy(newStr, userStr);
printf("%s\n", newStr);
return 0;
}
Computers and Technology
1 answer:
Kryger [21]3 years ago
8 0

Answer:

Following are the complete code to the given question:

#include <stdio.h>//header file

#include <string.h>//header file

#include <stdlib.h>//header file

int main()//main method  

{

  char userStr[100] = "";//defining a char array  

  char* newStr = NULL;//defining a char pointer  

  strcpy(userStr, "Hello friend!");//use strcpy method that holds char value  

  newStr = (char *)malloc(strlen(userStr));//defining a char variable that use malloc method

  strcpy(newStr, userStr);//use strcpy method that holds newStr and userStr value

  printf("%s\n", newStr);//print newStr value

  return 0;

}

Output:

Hello friend!

Explanation:

In this code inside the main method a char array "userStr" and a char type pointer variable "newStr" holds a value that is null, and inside this strcpy method is declared that holds value in the parameters.

In this, a malloc method is declared that uses the copy method to hold its value and print the newStr value.

You might be interested in
Marly is using her smartphone to review a webpage that she created. The formatting and alignment of webpage elements is incorrec
Margaret [11]

Answer:

She needs a responsive design

Explanation:

The website needs to detect what kind of device the user is using. It could be by the window size (not very accurate), or a piece of code to figure out the device being used. Once it knows what device is being used, and the size of the page, it should change its layout to fit the design.

3 0
3 years ago
Write a program that calls a function to change a variable value from miles to kilometers.
Aneli [31]

Answer:

#include <iostream>

using namespace std;

void miles_to_km(float &miles)//function to convert miles to kilo meters.

{

   miles=miles*1.6;

}

int main() {

   float miles;

   cout<<"Enter the miles"<<endl;

   cin>>miles;//taking input of the miles..

  miles_to_km(miles);//calling function that converts miles to km..

   cout<<"The number of km is "<<miles<<endl;//printing the km.

return 0;

}

Output:-

Enter the miles

54

The number of km is 86.4

Explanation:

I have created  a function miles_to_km of type void which has the argument miles passed by reference.In the function the variable miles is converted to kilo meters.Then in the main function the function is called with the value prompted from the user.Then printing the changed value.

7 0
3 years ago
Which tool would be the best choice for removing and replacing the motherboard bios chip?
mamaluj [8]

An <u>IC extractor</u> would be the best choice for removing and replacing the motherboard bios chip.

<h3>What is a computer hardware?</h3>

A computer hardware can be defined as a physical component of an information technology (IT) or computer system that can be seen and touched.

<h3>The hardware components of a computer.</h3>

Some examples of the hardware components of a computer system and these include:

  • Random access memory (RAM).
  • Read only memory (ROM).
  • Central processing unit (CPU)
  • Keyboard
  • Monitor
  • Mouse
  • Motherboard bios chip

In Computer technology, an <u>IC extractor</u> would be the best choice for removing and replacing the motherboard bios chip.

Read more on motherboard bios chip here: brainly.com/question/17373331

#SPJ1

8 0
2 years ago
Which statements about viruses are true? select the four statements that are true. select the four statements that are true. all
navik [9.2K]
<span>A) All viral genomes contain both DNA and RNA. FALSE. Viruses contain the smallest necessary amount of genetic information packaged in a capsule composed of proteins. Containing both DNA and RNA would be a redundancy that would unnecessarily increase the size of the virus and make it more difficult for the virus to penetrate a cell. B) A retrovirus contains RNA. TRUE. By definition a retrovirus contains single-stranded positive-sense RNA instead of DNA. C) HIV contains two identical strands of DNA. FALSE. HIV is a retrovirus and, therefore, contains RNA instead of DNA. D) HIV contains reverse transcriptase. TRUE. HIV is a retrovirus that contains an RNA genome. All retroviruses require reverse transcriptase to convert their genome from RNA to DNA once the virus has been entered the cell. E) The capsid enters the host cell if the virus is enveloped. TRUE. Viruses are to large to enter a cell by passive diffusion or active transport. The only remaining major form a transport into the cell is endocytosis, or being enveloped. F) All RNA-containing viruses are retroviruses. FALSE. By definition a retrovirus contains single-stranded positive-sense RNA. Viruses can contain RNA in other forms (ie double-stranded) and would, therefore, not be considered a retrovirus. G) Enveloped viruses bud from the host cell. TRUE. Viruses are to large to enter a cell by passive diffusion or active transport. The only remaining major form a transport into the cell is exocytosis. For a virus to exit the host cell and infect other cells, they must exit by exocytosis, or budding.</span>
4 0
3 years ago
Which of the steps below describe saving a newly created file?
xenn [34]
Saving a newly created file

Select Save from the File menu.

Name the file.
6 0
4 years ago
Read 2 more answers
Other questions:
  • A bank system mainframe is struck by a DDoS attack and goes offline. Customer’s cannot log on to their accounts. Which element o
    11·1 answer
  • How does color affect your mood?
    11·2 answers
  • A user printed several documents to a shared network copier and noticed that they have very faint color density. A technician in
    9·1 answer
  • The Android operating system was invented by ______.
    13·1 answer
  • How is energy expended in active transport​
    10·1 answer
  • Write an algorithm using pseudocode to input numbers . reject any numbers that are negative and count how many numbers are posit
    10·1 answer
  • Does anyone know the answer for question d (questions in the picture btw)
    7·1 answer
  • How many country on earth​
    6·2 answers
  • What is the best use of network in homes
    15·2 answers
  • What is phishing?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!