C :: Read Doubles From A Binary File
May 6, 2014
I use the following function to read doubles from a binary file:
Code:
int64_t read_current(FILE *input, double *current, uint64_t position, uint64_t length)
{
printf("asked for %" PRIu64" samples
",length);
printf("reading from %" PRIu64 " to %" PRIu64 "
",position,position+length);
union{
double d;
uint64_t i;
}
[code]...
As long as position+length doesn't exceed the end of the file, all is well. However, if it does, weird things start to happen. In particular, the apparent length of the file (that is, the value of "read" after the function has finished) becomes dependent on "length"). I know that "position" is never past the end of the file.
View 12 Replies
Nov 24, 2014
When reading a binary .img why is it when you read it by slurping in the file, then save it to a string and cout, you don't see the binary but random garbage?
View 11 Replies
View Related
Apr 22, 2013
I am trying to get the code to read from the txt file one bite at a time and then write this bite into the binary file but i cant seem to get it working.
FILE *fpcust, *fpcustbin; //<<<<<-----point to both sales and customers text files, and the new .bin files for both
char buffer;
int ch;
int ch1;
fpcust = fopen("c:customers.txt", "r"); //<<<<-----pointing to the file
fpcustbin = fopen("c:customers.bin", "wb"); //<<<<<-----pointing to the new binary file, opening in writing binary
[Code]...
View 3 Replies
View Related
Oct 12, 2014
I have this file want to read it source code [URL] ....
View 10 Replies
View Related
Nov 9, 2013
I'm trying to do file compression/decompression in C and I need to handle one bit at a time.
I currently try to do:
unsigned char byte = fgetc(fptr);
and later
byte >>= 1;
but the problem is that I have to use the first bit of the byte and then treat the next 8 bits as one byte. The byte usage keeps shifting over in this way. It's probably quite clear that I'm a bit lost.
View 1 Replies
View Related
Feb 26, 2012
Trying to write very simple code to read a 4 byte int from a file.
code:
int tester;
FILE *fp;
fp=fopen("/home/bdluser/skeleton.blx","rb");
fread(&tester,sizeof(int),1,fp);
printf("tested 1 byte read should be 1: %i",tester);
I have tried editing the binary file....it outputs similar large numbers
00000000000000000000000000000001 outputs 808464432
0x00000001 outputs 808482864
0x10000000 outputs 808548400
10000000000000000000000000000000 outputs 808464433