fixed 1-17 being wrong and unfinished

This commit is contained in:
celso 2022-11-09 07:19:41 -03:00
parent 9e40e33700
commit 39604128b6
1 changed files with 6 additions and 3 deletions

7
1-17.c
View File

@ -8,8 +8,9 @@ int ggetline(char line[], int maxline){
if(i<maxline-2){
line[i]=c;
}
else if(i==maxline-1){
line[i]='\0';
else if(i==maxline-2){
line[i]='\n';
line[i++]='\0';
return i;
}
}
@ -31,7 +32,9 @@ int main(){
char longline[MAXLINE]; /* line to print */
while ((len = ggetline(line, MAXLINE)) >0){
copy(longline, line);
if (len>80){
printf("%s\n", longline);
}
}
return 0;
}