//the program reads in a set of lines of text and prints the longest text. #include <stdio.h>using namespacestd;#defineMAXLINE 1000intGetlineCharLine[],intLim);voidCopyChar from[],Charto[]);intMain () {intnum; intmax=0; CharLine[maxline]; CharLongest[maxline]; while((Num=getline (line,maxline)) >0) { if(num>max) {Max=num; Copy (line,longest); }} printf ("Longest text behavior:%s", longest); return 0;}intGetlineCharLine[],intLim) { intCount=0; intC; for(count;count<lim&& (C=getchar ())!=eof;++count) {Line[count]=C; if(c=='\ n'){ ++count; Line[count]=' /'; Break; } } returncount;}voidCopyChar from[],Charto[]) { intI=0; while((to[i]= from[i])! =' /') { ++i; } return;}
Note : line[count]= ' "If not this sentence, then the line character array is not closed, and the end is full of garbled" Hot Hot Hot Hot hot hot iron hot ... "
Character array manipulation