chunker.

Well, if I can’t sleep, I can at least get my code spit out.

#include [stdio.h]

#define WORKSPACE “./Workspace/”
#define LINE_LENGTH 160

int chunk_size = 43;

main()
{
int i = 0, wrote = 0;
FILE *fp;
char filename[LINE_LENGTH], insuck[LINE_LENGTH];

sprintf(filename, “%s%d”, WORKSPACE, i++);
if ((fp = fopen(filename, “w”)) == NULL) exit(1);

while (fgets(insuck, LINE_LENGTH, stdin) != NULL) {
fprintf(fp, “%s”, insuck); wrote++;
if (wrote >= chunk_size) {
fclose(fp);
sprintf(filename, “%s%d”, WORKSPACE, i++);
if ((fp = fopen(filename, “w”)) == NULL) exit(1);
wrote = 0;
}
}

fclose(fp);

exit(0);
}

Related Posts

  • 9653- WednesdayMarch 18, 2009 9653- Wednesday Bro's girlfriend / possible mother to his kid Shannon has been found, and she and her […]
  • 9638 – Thursday – repairing internet connection on the eeeMarch 5, 2009 9638 – Thursday – repairing internet connection on the eee See entry comments for mysql code snips in use. Saving on j:/uiia/qmysql/ --"modem […]
  • Wednesday – 9396 –August 13, 2008 Wednesday – 9396 – I officially know more about Rsync than I ever thought I would. It's a mighty handy […]
  • 9335 – ThursJune 26, 2008 9335 – Thurs That Meme - Post 3 things you've done in your lifetime that you don't think anybody else […]
  • 9268 – Sunday –May 4, 2008 9268 – Sunday – Bagel, cream cheese, strawberries and pineapple for breakfast - BHK and I slowly worked […]

Leave a Reply