Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ program 2. Write a function my_strcpy(char str1[], char str2[], int str2_size, int p1, int p2) which copies the C-string in str1 (from index p1
C++ program
2. Write a function my_strcpy(char str1[], char str2[], int str2_size, int p1, int p2) which copies the C-string in str1 (from index p1 to index p2) to str2 (size is str2_size). Your function has to check if str2 has enough space. If there is no enough space in str2 to accommodate the string, print an error message but not copy anything to str2. Also write a driver program to test your function. Sample program output: str1 = I love C++ so much! str1 = I love C++ so much! Copy from str1 to str2 ... Copy from str1 to str2 ... Start position: 3 Start position: 3 End position: 13 End position: 10 >> Error str2 = love C++ >> str2 does not have enough space. Try again? (y) n >> Copy failed. Try again? (y) y Have a nice dayStep 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