I want my program to replace tabs with spaces.1tab=4spaces.Example:aa(tab)aaa(tab)a(tab)a aaa(tab)=aaxxaaaxaxxxaxxxx I think that my program works corectly but when a write aaa(tab)a it must show aaaxa but it is aaaxxxxxa.Please for help!!! That is my code:
Code:
#include <stdio.h>

int next_tabstop(int col) {
    return(4 - col%4);


}
int main() {
    int ch;
    int col=0;
    while((ch=fgetc(stdin))!=EOF){
        if(ch=='\n'){
            col=1;
            fputc(ch,stdout);
        } else{
            col++;
            if(ch!='\t'){
            fputc(ch,stdout);   
            }else {
                int sp=next_tabstop(col);
                col+=sp;
                while (sp>0){
                 fputc('x',stdout);
                 sp--;
                }
               
            }
           
    }


    }


    return 0;
}