eighteenth exercise
This commit is contained in:
parent
39604128b6
commit
16d0011d18
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue