diff options
| author | Sadeep Madurange <smadurange@users.noreply.github.com> | 2022-01-26 20:01:03 +0800 |
|---|---|---|
| committer | Sadeep Madurange <smadurange@users.noreply.github.com> | 2022-01-26 20:01:03 +0800 |
| commit | 6943c1eca4383474260aa04a59365de59e50f8c6 (patch) | |
| tree | c628badd25eff7a36fa7cd179432ec96a6df67c9 /5 | |
| parent | 4a0ac12c8574a42f3256c5afcc76aa450bd70893 (diff) | |
| download | k&r-exercises-6943c1eca4383474260aa04a59365de59e50f8c6.tar.gz | |
5.11
Diffstat (limited to '5')
| -rw-r--r-- | 5/11.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -22,7 +22,7 @@ void detab(char *s, char *t, int *tablist, int tablistc); int main(int argc, char *argv[]) { int colv[MAXTABLIST], colc; - char op, s[MAXTEXT], t[MAXTEXT]; + char op, s[MAXTEXT + 1], t[MAXTEXT + 1]; if ((argc != 2 && argc != 3) || ((op = argv[1][1]) != 'e' && op != 'd')) { printf("Usage: -e 5,3...\n"); @@ -88,3 +88,19 @@ int gettablist(char *s, int *t) { return j; } + +void entab(char *s, char *t, int *tablist, int tablistc) { + int i, j, k; + + if (tablistc == 1) { + for (i = 0, j = 0; i < MAXTEXT && j < MAXTEXT && (t[j] = s[i]) != 0; i++) { + if (s[i] == '\t') { + for (k = 0; k < TABSIZE && j < MAXTEXT - 1; k++, j++) + t[j] = ' '; + } else + j++; + } + } + + t[j] = 0; +}
\ No newline at end of file |
