Spaces-to-tabs converter, updated version I recently posted Spaces To Tabs Converter but it had lots of bugs, so I rewrote the code. I wanted to ask, is it good code? I didn't find any bugs.

#include &lt;stdio.h&gt;
#define TABVALUE 4
#define ARRAYSIZE 3

void emptyArray(int *a);

int main(void) {
    int c, d, s;
    int savedChars[ARRAYSIZE];
    c = s = d = 0;
    while ((c = getchar()) != EOF) {
        if (c == ' ') {
            s = 0;
            s++;
            for (int j = 0; j &lt; TABVALUE - 1; j++) {
                d = getchar();
                if (d != EOF) {
                    savedChars[j] = d;
                    savedChars[j + 1] = '\0';
                    if (d == ' ') {
                        s++;
                    } else {
                        break;
                    }
                }
            }
            if (s == TABVALUE) {
                emptyArray(savedChars);
                putchar('\t');
                s = 0;
            } else {
                putchar(c);
                for (int i = 0; i &lt; 3; i++) {
                    if (savedChars[i] != '\0') {
                        putchar(savedChars[i]);
                    }
                }
            }
        } else {
            if (c != EOF) putchar(c);
        }
    }
    return 0;
}

void emptyArray(int *a) {
    for (int i = 0; i &lt; ARRAYSIZE; i++) {
        a[i] = '\0';
    }
}
A chunk of memory that is used to temporarily queue up content before it is eventually flushed is typically called a buffer.  A typical variable name would be buffer or buf.

You defined constants TABVALUE and ARRAYSIZE.  It looks like ARRAYSIZE is dependent on TABVALUE, so you shouldn't hard-code both 4 and 3.  You also shouldn't hard-code 3 in the for loop.

The program outline is basically


while ((c = getchar()) != EOF) {
    if (c == ' ') {
        /* Huge chunk of buffer manipulation code here... */
    } else {
        if (c != EOF) putchar(c);
    }
}



You've already ascertained that c is not EOF in the while loop, so if (c != EOF) is pointless.  I would also recommend inverting the test so that there isn't a huge chunk of code before the else.  This outline is equivalent to your logic:

while ((c = getchar()) != EOF) {
    if (c != ' ') {
        putchar(c);
    } else {
        /* Huge chunk of buffer manipulation code here... */
    }
}


The first space encountered gets stored as c, but subsequent spaces get written to the savedChars buffer.  The code would be simpler if you just wrote the first space to the buffer too.

I'm not convinced that you need a savedChars buffer, though.  The buffer will only contain a string of spaces, possibly followed by a non-space character at the end.  You should be able to do the job using just the s count and the final character d.