خرید بک لینک

Vote count: 0

I am learning how to handle files in C. When I try to read a binary file, everything runs fine but I get a garbage output. Here is my code:

FILE *ptr;
struct file rec;

ptr=fopen("sample.bin","rb");
while(!feof(ptr))
{
fread(&rec,sizeof(struct file),1,ptr);
printf("%d, %d, %d, %d, %f, %x, %s, %f, %c, %d, %u, %d, %x, %d, %d, %u, %fn",
rec.a, rec.b, rec.c, rec.d, re.e, rec.f,rec.g, rec.h, rec.i, rec.j, rec.k, rec.l,rec.m, rec.n, rec.o, rec.p, rec.q);
}

So I am thinking I might need to use more than one fread(). Can Someone show me how to use it?

Note:This is how the sample.bin looks like:

0000 0000 0101 002f 1000 0000 00f4 0d0a 4540 8f94 e9ff ffff ffff 636c 6f63 6b00 00c0 ece0 3b69 b736 a1ea ffff ffff 2700 0000 0000 8dcb 0cce 0301 7294 cc02 0000 0000 0000 42bf

asked 1 min ago

برچسب: read binary file,read binary file python,read binary file c,read binary file java,read binary file linux,read binary file windows,read binary file online,read binary file in r,read binary file unix,read binary file in notepad, نویسنده: استخدام کار تاريخ: يکشنبه 24 مرداد 1395 ساعت: 10:13

صفحه بندی