Friday, March 4, 2011

CHARACTER STUFFING PROGRAM


#include<stdio.h>
#include<conio.h>
#include<string.h>
void start();
void end(char);
FILE *of;
FILE *cf;
int b,i=0;
char c,a='@',z='$',d[25];
void main()
{
clrscr();
cf=fopen("andy.txt","r");
of=fopen("ani.txt","w");
do
{
c=getc(cf);
d[i++]=c;
}while(c!=EOF);
fprintf(of,"%c",a);
for(i=0;i<strlen(d);i++)
{
if(d[i]==' '||d[i]=='\t')
{
end(d[i]);
}
else if(d[i]=='\n')
{
start();
}
else if(d[i]==EOF)
{
fprintf(of,"%c",z);
}
else
{
fprintf(of,"%c",d[i]);
}
}
printf("file sucessfully stuffed");
fclose(cf);
fclose(of);
getch();
}
void start()
{
fprintf(of,"%c\n",z);
fprintf(of,"%c",a);
}
void end(char k)
{
fprintf(of,"%c",z);
fprintf(of,"%c",a);
fprintf(of,"%c",k);
fprintf(of,"%c",z);
fprintf(of,"%c",a);
}

No comments:

Post a Comment