Question: Write a function repeat which duplicates the contents of a string. For example, the following code should output TestTestTest to the screen: char str[1024] =
Write a function repeat which duplicates the contents of a string.
For example, the following code should output TestTestTest to the screen:
char str[1024] = "Test "; repeat(str, 3); printf("%s ", str);
Attention: For the strcat function, the destination and source strings must not be identical! Hint: You will also need the function strcpy
Hint 1: string.h is already included in the program. So you can use strcat, strcpy and all other string functions without any additional steps.
Hint 2: The number of repetitions is always >= 1
Sample Input:
3 Hello
Sample Output:
HelloHelloHello
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
