Question: Write a C function with the following prototype: int resize (char s[], int array_size, int new_size); You function should change the size of the C-string

Write a C function with the following prototype:

int resize (char s[], int array_size, int new_size);

You function should change the size of the C-string stored in the array s. If new_size is shorter than the current length of the string, truncate the string. If new_size is longer than the current length of the string, pad the end of the string with spaces, but don't exceed the size of the array, which is stored in array_size. Return the new size of the string as the value of the function. Please be thorough with comments.

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!