Program to replace the tab stops to 8 positions.

#include <stdio.h>
#define MAX 100
main()
{
char ch[MAX],character;
int i=0,count=0,tab,j=0;
printf("Enter the data with tabs:\n");

do
{
character=getchar();
ch[i++]=character;
}
while(character!=EOF);
ch[--i]='';
printf("\nAfter repalcing the tabs with tab stops at 8 positions:\n");
i=0;
while(ch[i]!='')
{
if(ch[i]!='\t')
{
printf("%c",ch[i]);
if(ch[i]=='\n')count=0;
else
count++;
}
else
{
tab=count%8;
for(j=1;j<=8-tab;j++)
printf(".");
count+=8-tab;
}
i++;
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s