The following program (under Turbo C++) compiles fine with no
error but will not link. Linker reports "Break on Link" with no other
message to give any clue as to why it doesn't link.
Does anybody have any ideas at all as to what might be wrong?
-- dk (Dusan Kubias)
/* FILENAME: 64KCHOP.C */
/* DESCRIPTION: Chops a file into 64K subfiles */
/* AUTHOR: James Wiebe */
/* DATE: Wed Apr 2, 1997 */
/* NOTES: */
/* Errorlevel 2: User quit after 1000 64K blocks written out */
/* 1: An input or output file could not be opened */
/* 0: Program finished normally */
/* HISTORY: */
/* Wed Apr 2, 1997 */
/* First cut: User must specify all the subfile names (tedious) */
/* (called that 64KCHOP1.C) */
/* Second cut: Program generates numbered filename extensions */
#include
#include
#include
int main (char *usercmnd)
{
FILE *pmyinfile; /* Pointer to the huge input file */
FILE *pmyoutfile; /* Pointer to output files */
char buf[4096]; /* temporary transfer buffer */
/* ("usercmnd" is input filename) */
char pnamepart[20]; /* name part of input file */
char pnewnamepart[20]; /* new name part for output file */
char pextpart[10]; /* numbered sub extension */
char *puseroutfilename; /* name of an output file */
int i; /* Handy loop counter */
int j; /* Handy secondary loop counter */
if ((pmyinfile = fopen(usercmnd, "r")) == NULL)
{
fprintf(stderr, "Cannot open input file to read.\n");
return 1;
}
/* seek to the beginning of the file */
fseek(pmyinfile, 0, SEEK_SET);
/* Get the name part for assignment of numbered extensions */
i=0;
while(
(usercmnd[i] != '.')
&&
(usercmnd[i] != 0)
&&
(usercmnd[i] != ' ')
)
{
pnamepart[i] = usercmnd[i];
i++;
}
pnamepart[i] = 0; /* (C requires null-terminated strings) */
i = 0;
/* Slam out the 64K blocks */
while (!eof(1))
{
/* Generate an output filename */
if (i > 999)
/* Out of extensions; get another name part */
{
do
{
fprintf(stderr, "Out of extensions. Specify a unique new name part, or Q to
quit.\n");
scanf("%8s", pnamepart);
if (strcmp(pnamepart, "Q"))
{
fprintf(stderr, "User decided to quit after doing 1000 64K blocks.\n");
fclose(pmyinfile);
return 2;
}
}
while (
(strchr(pnewnamepart, '.'))
||
(strcmp(pnewnamepart, pnamepart))
);
strcpy(pnamepart, pnewnamepart);
i = 0;
}
/* Generate the particular filename for this 64k block */
puseroutfilename = strcat(pnamepart, ".");
itoa(i, pextpart, 10);
puseroutfilename = strcat(puseroutfilename, pextpart);
if ((pmyoutfile = fopen(puseroutfilename, "w")) == NULL)
{
fprintf(stderr, "Cannot open output file ");
fprintf(stderr, puseroutfilename);
fprintf(stderr, " to write.\n");
return 1;
}
/* read a 64K byte block of the data to be written out */
/* (In 16 4K chunks) */
for (j=0; j<16; j++)
{
fread(buf, (size_t)4096, 1, pmyinfile);
/* write it to the file specified by the user: */
fwrite(buf, (size_t)4096, 2, pmyoutfile);
if (eof(1))
{
break;
}
} /* end of for loop to write 64K block to a file in 4K chunks */
fclose(pmyoutfile);
/* Set the next extension for the next 64K file */
i++;
} /* End of while loop to write 64K blocks, each to a file */
fclose(pmyinfile);
return 0;
} /* End of 64K Chop program */
... (hic) BWave 2.10 (hic) BWave 2.10 * My computer is drunk ...
___ Blue Wave/QWK v2.20 [NR]
--- Platinum Xpress/Win/Wildcat5! v2.0
---------------
* Origin: Doctor On Board BBS: Niagara's Medical Host for Info (1:247/101)
|