So this is likely a straight forward issue with my use of either fwrite, or fread. Here is a full listing of my test code, and the output it gives. Sorry for the mingling of microsoft specific "safe" calls.
And the output:
short *uArr = new short;
short *uComp = new short;
for ( int i=0 ; i<50000 ; i++ )
uArr[i] = (short)(rand()%0xFFFF);
int nWriteCount = 0;
if ( fopen_s(&fOut, "testWrite", "w") == 0 )
nWriteCount = fwrite(uArr,sizeof(short),50000,fOut);
printf( "Wrote %d shorts to file.\n", nWriteCount);
int nReadCount = 0;
if ( fopen_s(&fIn, "testWrite", "r") == 0 )
nReadCount = fread(uComp,sizeof(short),50000,fIn);
printf ( "Read %d shorts from file.\n", nReadCount);
delete  uArr;
delete  uComp;
So it seems like a pretty straightforward task, basically just writing a large array of shorts to file, and then reading them back.
Wrote 50000 shorts to file.
Read 49 shorts from file.
Of not it fails after reading 49 shorts, so the value where it fails is : -274.
Thanks for any input.