Replace tabs with spaces
First of all, it is not exactly doing what is expected of detab. The visual appearance of the detabbed text shall remain the same. You need to insert as many spaces as required to reach the next tab stop, not necessarily 4 of them.

For example, a string ab\tc should become

ab  c


(2 spaces inserted) whereas your code produces

ab    c

detab does not zero-terminate the string. It is an (un)lucky coincidence that the code produces meaningful output.
The limit condition is only tested during the tab expansion. A long sequence of ordinary characters will overrun the buffer.