From c24973af02bc33f2f5f25d37e22ca91da5de3c47 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sat, 4 Jun 2022 12:11:15 +0530 Subject: inital commit --- 1.18.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 1.18.c (limited to '1.18.c') diff --git a/1.18.c b/1.18.c new file mode 100644 index 0000000..36f5ad9 --- /dev/null +++ b/1.18.c @@ -0,0 +1,35 @@ +#include + +#define MAXLINE 1000 + +int +main(void) +{ + int input, i, non_blank; + char str[MAXLINE]; + + i = 0; + non_blank = -1; + + while ((input = getchar()) != EOF) { + while (input != '\n' && input != EOF) { + str[i] = input; + + if (input != ' ' && input != '\t') + non_blank = i; + + ++i; + input = getchar(); + } + + if (non_blank == -1) + continue; + + str[non_blank+1] = '\0'; + printf("%s\n", str); + + i = 0; + } + + return 0; +} -- cgit v1.2.3