Questions tagged [fread]

A binary-safe file read function in C/C++/PHP that returns the specified number of bytes from a stream. Also a fast csv parser in R's data.table package.

References:

1613 questions
0
votes
1 answer

matlab reading a binary file

This is suppose of be very simple but I just can't get it right, probably because I don't understand something very basic. I'm trying to figure out how to read a binary file into matlab which consists of 7 variables, each variable is written in 2…
BioSP
  • 518
  • 4
  • 15
0
votes
2 answers

why does fread not release memory on ios

My coworker and I are having a killer of a time trying to figure out this problem. We want to parse a file (custom made 3d object file). The problem is in using the stdio function calls like fread, fseek, etc. In the below code, when I check the…
Raigex
  • 1,205
  • 12
  • 32
0
votes
1 answer

fwrite in c going in an infinite loop

I am trying to update records in a .DAT file using fread and fwrite but somehow the loop runs infinitely. My code is: FILE *fq; Employee eme; long int recsize_eme; recsize_eme=sizeof(eme); fq=fopen("EME.DAT","rb+"); if(fq==NULL) { fq=fopen(…
Abhishek
  • 33
  • 7
0
votes
3 answers

using fread on triple pointer in C

I know how to read a file into a 2d array using for loops to direct where you are storing the data in C, but what I am interested in is if you can use one fread() call to do this. That is, can I do something like this: int A[5][5]; fread(&A,…
user912447
  • 696
  • 1
  • 11
  • 31
0
votes
2 answers

Wrong values after reading back data with fread in C

I am using tmpfile() to create a file (so it's automatically opened in binary mode). Then I write some floats in it with fwrite(). All these floats are > 0. The problem is that when I try to read these values (that are >0) back with fread(), I get…
user1493046
  • 352
  • 1
  • 3
  • 17
0
votes
1 answer

Issue with fwrite and fread

Having an issue with my fwrite() and fread() dealing with a binary file here is my source code, and towards the bottem are my read and write. Right now it is returning 'jake' when I run it, and nothing else. I was told to write a dump buffer…
Zach M.
  • 1,188
  • 7
  • 22
  • 46
0
votes
3 answers

fread'ing and fwrite'ing a structure that contains pointers

gcc (GCC) 4.7.0 c89 Hello, I have the following structure that I am trying to fwrite and fread. However, because my device and resource are pointers. The fwrite will read the pointer values and not the data. I cannot use a array for the device or…
ant2009
  • 27,094
  • 154
  • 411
  • 609
0
votes
1 answer

using fwrite and fread to save and retrieve a sample malloc'd database

gcc (GCC) 4.7.0 c89 Hello, I have trying to save a database of rows to a file (db.dat) using fwrite to write it and retrieve it using fread. However, when I retrive it with fread the data is empty. I not sure if I should malloc some memory before…
ant2009
  • 27,094
  • 154
  • 411
  • 609
0
votes
2 answers

Rapid calls to fread crashes the application

I'm writing a function to load a wave file and, in the process, split the data into 2 separate buffers if it's stereo. The program gets to i = 18 and crashes during the left channel fread pass. (You can ignore the couts, they are just there for…
Slynk
  • 527
  • 5
  • 9
0
votes
1 answer

Reading TAG2 of a mp3 file in a c program

I wrote a c program to read a MP3 file and print the TAG2 fields. The source code is: void main(void) { FILE *w; char c[10]={0}; int ver, flag, size; w=fopen("test.mp3,"rb"); fread(c,1,3,w); printf("TAG2…
katy
  • 1
  • 2
0
votes
1 answer

Problems reading a binary file with fread function

What I want to do is to read the contents of a '.d' binary file and store them in an array. So I wrote the following codes: void viewFile() { unsigned char inFileData[SIZE]; char fileName[SIZE]; int numRead; FILE *inBinFile; …
David Chu
  • 1
  • 1
0
votes
2 answers

Display popup after PHP fread finishes

I want to issue a popup or something to remind users to perform a second action after the first action is done. The first action is fwrite($fp, $str); $read = fread($fp, 16); $read = explode(";", $read); if ($read[0] != "OK") { echo "Write…
0
votes
2 answers

Read file into memory?

I can seem to only read file into memory if I explicitly declare the buffer size. This works #include int main(){ FILE *fp = fopen("test.log", "rb"); char buffer[37]; fread(buffer, 1, 36, fp); printf("%s", buffer); } This will add…
Zombo
  • 1
  • 62
  • 391
  • 407
0
votes
4 answers

Reading part of a file in C using fread() and fseek()

I'm trying to read a file into a buffer in blocks of size BLOCK_SIZE (currently equal to 1000 unsigned chars). My code initially finds the number of blocks it will have to read in order to read the entire file (usually 2-4), then iterates through a…
user144724
0
votes
1 answer

php script using fread() times out - was working fine for about a year, but now it's failing

I'm using a session controlled script to allow users to get files from my server that are outside the web-readable area of the site. The problem lately has been that the files are never finishing. The browser says it's all done, but the files aren't…
Lido
  • 15
  • 6