Implementation of exercise 1-9: copying and printing input text to output, removing redundant spaces.

This commit is contained in:
Reina Harrington-Affine 2025-08-14 06:53:38 +00:00
parent 7be84d6b88
commit 7d26e0ffc7

28
KNR C/ex1_9.c Normal file
View file

@ -0,0 +1,28 @@
#include <stdio.h>
int main(){
int a = getchar();
int state = 0;
while (a != EOF){
if (state == 1){
if (a != ' '){
putchar (a);
}
} else {
putchar(a);
}
if (a == ' '){
state = 1;
} else {
state = 0;
}
a = getchar();
}
return 0;
}