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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started