Question: Complete the code using the given Parameters. Recoding not available .. Question : Write a function reverse(s) that reverses an input string s. Use it
Complete the code using the given Parameters. Recoding not available ..
Question : Write a function reverse(s) that reverses an input string s. Use it to write a program that reverses its input one line at a time.
#include
#define MAXLINE 1000
int getline2(char line[], int maxline); void copy (char to[], char from[]); void reverse(char source[], char target[]);
int main() { int len; int max; char line[MAXLINE]; char longest[MAXLINE]; char rline[MAXLINE]; max=0; while((len = getline2(line, MAXLINE)) > 0){ if(len > max){ max = len; copy(longest, line); } } if(max > 0) printf("%s", longest); reverse(longest, rline); printf(" reverse: %s ", rline);
return 0; }
int getline2(char s[], int lim){ int c, i; for (i=0; i void copy (char to[], char from[]){ int i; i=0; while((to[i] = from[i]) != '\0' ) ++i; } void reverse(char source[], char target[]){ \\ Your Code Here }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
