File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+ #define MAXSIZE 1024
3+
4+ int _getline (char line [], int maxSize );
5+
6+ int main () {
7+ int tabSpace = 5 ;
8+ int len ;
9+ char line [MAXSIZE ];
10+ char clean [MAXSIZE ]= {"" };
11+ while ( (len = _getline (line ,MAXSIZE )) > 0 )
12+ {
13+ int i = 0 ,count ,j = 0 ;
14+ if (len > 1 )
15+ while (line [i ]!= '\0' ) {
16+ count = 0 ;
17+ if (line [i ]== ' ' ) {
18+ while (line [i ]== ' ' ){count ++ ;i ++ ;}
19+ int tab = count /tabSpace ;
20+ int space = count %tabSpace ;
21+ for (int k = 0 ;k < tab ;k ++ )
22+ //clean[j++]='\t';
23+ clean [j ++ ]= '*' ;
24+ for (int l = 0 ;l < space ;l ++ )
25+ clean [j ++ ]= '-' ;
26+ }
27+ else clean [j ++ ]= line [i ++ ];
28+ }
29+ }
30+ printf ("\nYour cleansed output: \n%s" ,clean );
31+ }
32+
33+ int _getline (char l [], int max ) {
34+ int c ,i = 0 ;
35+ while (i < max - 1 && (c = getchar ())!= EOF && c != '\n' ) l [i ++ ]= c ;
36+ if (c == '\n' ) l [i ++ ]= c ;
37+ l [i ]= '\0' ;
38+ return i ;
39+ }
You can’t perform that action at this time.
0 commit comments