Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Which statements about the following piece of code are TRUE? ( Check all that apply ) char * repeated ( char * original, int n

Which statements about the following piece of code are TRUE? (Check all that apply)
char * repeated (char* original, int n){
int i, length = strlen(original);
char* newString = malloc (sizeof(char)* length * n +1);
char * helper = newString;
for (i =0; i < n; i++){
strcpy(helper, original);
helper = helper + length;
{
return newString;
}
- Each time helper is incremented by the length of the incoming string, its value jumps to the NULL character location in the newly built string
- helper is a pointer that initially points to the beginning of the string that is passed to function repeated
- strlen function returns the number of characters in the string passed to repeated, including the NULL character
- In order to perform memory clean-up, the free statement should be placed inside the function that calls function repeated but only after the resulting value is no longer needed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

What are the primary functions of advertising in a free economy?

Answered: 1 week ago

Question

3 What are the aims of appraisal?

Answered: 1 week ago

Question

7 Compare and contrast evaluative and developmental appraisal.

Answered: 1 week ago