Question
1. Determining required string size Purpose: avoiding array overrun Overview One of the basic operations is to concatenate two strings into a single string. In
1. Determining required string size
Purpose: avoiding array overrun
Overview One of the basic operations is to concatenate two strings into a single string. In order to do so the program must ensure that there is sufficient space in memory for concatenating two strings.
To do Code a function requiredStrLength() which accepts two strings and return the amount of memory in bytes that must exists if the two strings are to be concatenated. For example, if s1=This is and s2= a beautiful day! are to be concatenated to =This is a beautiful day! then the function should return 25. This is because s1 has 7 characters, s2 has 17 characters and we have to account for the \0 character representing the end of string.
Prototype int requiredStrLength(char *s1, char *s2);
Using String functions strlen() in your code
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