eighteenth exercise

This commit is contained in:
celso 2022-11-09 14:10:05 -03:00
parent 39604128b6
commit 16d0011d18
1 changed files with 32 additions and 0 deletions

32
1-18.c Normal file
View File

@ -0,0 +1,32 @@
#include <stdio.h>
#define MAXLINE 1000
int ggetline(char line[], int maxline){
int c, i, j;
j = 0;
for(i=0; i<maxline-1 && (c = getchar()) != EOF && c != '\n'; i
++){
if(j==0 && c == ' ' || c == '\t'){
continue;
}
if(c != ' ' || c != '\t'){
line[j]=c;
j++;
}
}
while(line[j-1] == ' ' || line[j-1] == '\t'){
j--;
}
line[j]='\0';
return i;
}
int main(){
char line[MAXLINE];
int len;
while((len=ggetline(line, MAXLINE)) > 0){
//NIGGER to visualize lack of trailing whitespace
printf("%sNIGGER\n", line);
}
return 0;
}