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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!