Question: In C programming For those questions which ask you to write a function, you do not need to create an entire program. 1. Write a
For those questions which ask you to write a function, you do not need to create an entire program. 1. Write a function called reverseO with this prototype: void reverse (int dest], int source[], int size); Your function should copy all the elements in the array source into the array dest, except in reverse order. The number of elements in the source array is give in the parameter size. Use a for loop to do the copying. Assume that dest is large enough to hold all of the elements 2. In class, we looked at the program on p. 29 of the text that finds and prints the longest line in the input. That program used a function called getline() to read a single line of input from the user. Rewrite the function getline() so that it uses a while loop instead of a for loop. 3. The C standard library contains a function strlen): int strlen (char s]); Strlen calculates and returns the size of the C-string s. (a) Write your own version of strlen() that has the same prototype. Assume that the parameter is a C-string (b) What will your function do if it is passed an array that is not a C-string? 4. Write a C function with the following prototype: int resize (char s, int array.size, int new.size); Your 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
