> Here's the erroneous code:
> ------------------------------
> fIn=fopen (argv[1], "r");
if(fIn == NULL) {
printf("%s open error - errno = %d\n", argv[1], errno);
exit(1);
}
> vz.InEnd=fread(InBuffer, 16*1024*1024, 1, fIn);
if(vz.InEnd <= 0) {
printf("%s read error - errno = %d\n", argv[1], errno);
exit(1);
}
You have the second and third arguments backwards. The second
argument is the size of each element you're reading, while the
third is the maximum number of elements you're reading. Your
fread() statement should look like this:
vz.InEnd=fread(InBuffer, 1, 16*1024*1024, fIn);
This tells fread() to read one byte at a time up to a
maximum of 16MB. (Don't worry about inefficiency, fread()
is pretty smart at optimizing these things.) The value
returned in vz.InEnd then becomes the number of bytes read.
Your original statement can only return two values: 1 if
you successfully read 16 megabytes of data, or zero if the
file is smaller than 16MB or you encountered an error.
Also, make sure that InBuffer is at least 16 megabytes long.
Otherwise, you'll overrun it and bad things will happen.
Do you really need to read the whole 16 megabytes into memory
at once? If your algorithm permits processing in smaller
chunks, you won't have to wait as long before it can start
chewing away at the data.
> fclose (fIn); fIn=0;
fIn = NULL; /* Consistent with documentation */
> printf ("Size: %d\n", vz.InEnd);
> ------------------------------
> How do I specify the drive and path of the needed libraries in OWC?
I'm afraid I'm not familiar with OWC. Check your documentation.
Worst case, you can try to run the compiler and linker with no
command-line parameters, or with garbage. If you're lucky, they
might spit out command templates. Otherwise, try including a
parameter like -h or --help.