Write a function named repeat that accepts a string (as a char+) and a number of repetitions as parameters and returns a heap-allocated string representing the parameter string concatenated that many...


Please give answer of that code


Write a function named repeat that accepts a string (as a char+) and a number of repetitions as<br>parameters and returns a heap-allocated string representing the parameter string concatenated that<br>many times. For example, the call repeat (

Extracted text: Write a function named repeat that accepts a string (as a char+) and a number of repetitions as parameters and returns a heap-allocated string representing the parameter string concatenated that many times. For example, the call repeat ("hello", 3) returns a new string "hellohellohello". If the number of repetitions is 0 or less, an empty string ("") should be returned. (You do not need to free any memory.) 1 char* repeat (char*s1, int repetitions ){ if (repetitions <= ø)="" {="" 2="" 3="" return="" 4="" }else{="" char*="" a="(char*)" calloc(repetitions,="" sizeof="" (s1));="" for="" (="" int="" i="1;" i=""><= repetitions="" ;="" i++){="" strcat="" (a,="" s1);="" 7="" 8="" return="" a;="" 10="" 11="" 12="" }="" 14="" n="" 3="">

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here