forked from topkecleon/telegram-bot-bash
/
mangrep.c
62 lines (53 loc) · 922 Bytes
/
mangrep.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define TRUE 1
#define FALSE 0
#define MAX 300
char* toupperStr(char* str);
int main ()
{
char line[MAX],space;
short i;
while (fgets(line,MAX,stdin)!=NULL)
{
if (!strncmp(toupperStr(line),"DESCRIPTION",strlen("DESCRIPTION")))
break;
}
while (fgets(line,MAX,stdin)!=NULL)
{
if (line[0]=='\n')
continue;
if(line[0]==' ' || line[0]=='\t')
{
i=0;
while((line[i]==' ' || line[i]=='\t') && line[i]!='\0')
i++;
space=FALSE;
for( ;i<strlen(line);i++)
{
if((line[i]=='\t' || line[i]==' ') && space==FALSE)
{
putchar(' ');
space=TRUE;
}
else
{
space=FALSE;
putchar(line[i]);
}
}
}
else
break;
}
return EXIT_SUCCESS;
}
char* toupperStr(char* str)
{
int i;
for (i=0;i<strlen(str);i++)
str[i]=(char)toupper((int)str[i]);
return str;
}