2022-11-09 06:59:58 -03:00
|
|
|
#include <stdio.h>
|
|
|
|
#define MAXLINE 1000 /* maximum input line length */
|
|
|
|
|
|
|
|
/* ggetline: read a line into 'line', return length */
|
|
|
|
int ggetline(char line[], int maxline){
|
|
|
|
int c, i;
|
|
|
|
for (i=0; (c=getchar()) != EOF && c!='\n'; i++){
|
|
|
|
if(i<maxline-2){
|
|
|
|
line[i]=c;
|
|
|
|
}
|
2022-11-09 07:19:41 -03:00
|
|
|
else if(i==maxline-2){
|
|
|
|
line[i]='\n';
|
|
|
|
line[i++]='\0';
|
2022-11-09 06:59:58 -03:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
line[i]='\0';
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
/* copy: copy 'from' into 'to'; asume to is big enough */
|
|
|
|
void copy(char to[], char from[]){
|
|
|
|
int i;
|
|
|
|
i = 0;
|
|
|
|
while((to[i] = from[i]) != '\0'){
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(){
|
|
|
|
int len; /* current line length */
|
|
|
|
char line[MAXLINE]; /* current input line */
|
|
|
|
char longline[MAXLINE]; /* line to print */
|
|
|
|
while ((len = ggetline(line, MAXLINE)) >0){
|
|
|
|
copy(longline, line);
|
2022-11-09 07:19:41 -03:00
|
|
|
if (len>80){
|
|
|
|
printf("%s\n", longline);
|
|
|
|
}
|
2022-11-09 06:59:58 -03:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|