0

I need to read a file in blocks of 200 bytes. So i'm using this:

int readData(char* data, FILE* fp){
sizeReturn=fread(data, 200, 1, fp);
cerr << sizeReturn << endl;
return sizeReturn;
}
while((size=readData(data, fp))>0)
    write(fileno(stdout), data, size);

I'm just trying to read the first 200 bytes, i know i need to do a fseek to advance, but i can't even read the first 200 bytes. It returns 0 bytes read. I need to read 200 by 200 on each loop because i'm sending it using udp, so i'm testing with a small number of bytes. Someone can help me to read the first 200 bytes.

Thanks

Vicky
  • 12,934
  • 4
  • 46
  • 54
Lefsler
  • 1,738
  • 6
  • 26
  • 46
  • I rolled back the edit because `cerr << sizeReturn << endl;` is most definitely not vaild C. – Vicky May 22 '13 at 12:34

1 Answers1

4

Solved:

Just fread(data, 1, 200, fp); I want to read one element with 200 bytes and not 200 elements with 1 byte

Thanks

Marco A.
  • 43,032
  • 26
  • 132
  • 246
Lefsler
  • 1,738
  • 6
  • 26
  • 46