#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
#include "string.h"
void main()
{
FILE *f1,*f2,*f3,*f4,*f5;
int i,n;
char *string,*filename;
clrscr();
printf("Enter filename: ");
scanf("%s",filename);
fflush(stdin);
f1=fopen(filename,"w");
if(f1==NULL)
{
printf("\nCouldn't open the file.");
exit(0);
}
printf("Write Something...\n");
scanf("%[^\n]",string);
fprintf(f1,"%s",string);
fclose(f1);
f1=fopen(filename,"r");
f2=fopen("a.txt","w");
for(i=0;i<(int)n/4;i++)
{
string[i]=fgetc(f1);
fputc(string[i],f2);
}
fclose(f2);
f3=fopen("b.txt","w");
for(i=(int)n/4;i
string[i]=fgetc(f1);
fputc(string[i],f3);
}
fclose(f3);
f4=fopen("c.txt","w");
for(i=(int)n/2;i<(int)(3*n)/4;i++)
{
string[i]=fgetc(f1);
fputc(string[i],f4);
}
fclose(f4);
f5=fopen("d.txt","w");
for(i=(int)(3*n)/4;i
string[i]=fgetc(f1);
fputc(string[i],f5);
}
fclose(f5);
fclose(f1);
}
Friday, June 26, 2009
PROGRAM TO SPLIT A FILE INTO 4 PARTS
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment