if linux use split command

On Tue, Aug 9, 2011 at 8:56 PM, Don <dondod...@gmail.com> wrote:
> #include <stdio.h>
> #include <stdlib.h>
>
> int main()
> {
>  char inFileName[80];
>  char outFileName[80];
>  int numSegments;
>  int bytesPerSegment;
>
>  printf("Enter file name:");
>  fgets(inFileName,80,stdin);
>  printf("Enter number of segments:");
>  scanf("%d", &numSegments);
>
>  FILE *f = fopen(inFileName, "rb");
>  if (!f) return 0;
>
>  // Get size of file to determine bytes per file segment
>  fseek(f, 0, SEEK_END);
>  int bytesPerSegment = 1 + (ftell(f) / numSegments);
>  fseek(f,0,SEEK_SET);
>  char *buffer = (char *)malloc(bytesPerSegment);
>  for(int segment = 0; segment < numSegments; ++segment)
>  {
>    sprintf(outFileName,"%s%d", inFileName,segment);
>    FILE *out = fopen(outFileName,"wb");
>    int len=fread(buffer, bytesPerSegment, 1, f);
>    fwrite(buffer, len, 1, out);
>    fclose(out);
>  }
>  return 1;
> }
>
> On Aug 9, 7:28 am, Divya Elangovan <divistyl...@gmail.com> wrote:
>> pls help me......its very urgent
>>
>> need a program to divide a file into equal parts(segments)
>>
>> --
>>
>> *
>>             **
>> *
>> *      **        **DIVI....*
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to 
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/algogeeks?hl=en.
>
>



-- 
Varun Jakhoria
...it's only about 0's & 1's

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to