Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

Students also viewed these Databases questions