question
- From: "Bill Cunningham" <nospam@xxxxxxxxx>
- Date: Sun, 13 Jan 2008 03:11:39 GMT
I wrote this small program to read a 512 block of binary data and write
the same to a file. My code compiled well. The only thing is when I ran the
compilers binary instead of a data file of 512 bytes I got one of 2048
bytes.
#include <stdio.h>
main(){
int buf[512];
FILE *fp;
fp=fopen("r.dsk","rb");
if (fp==NULL) {printf("Error"); exit(0);}
fread(buf,sizeof(int),512,fp);
fclose(fp);
fp=fopen("dat","wb");
if (fp==NULL) {printf("Error");}
fwrite(buf,sizeof(int),512,fp);
fclose(fp);}
Is it the code or some overhead from the compiler or linker?
Bill
The unix dd command copies exactly 512 bytes of I asked it too.
.
- Follow-Ups:
- Re: question
- From: Barry Schwarz
- Re: question
- From: Kenneth Brody
- Re: question
- From: Keith Thompson
- Re: question
- From: J. J. Farrell
- Re: question
- Prev by Date: Re: The machine stack and the C language
- Next by Date: Re: The machine stack and the C language
- Previous by thread: HONESTO AND VERY EASY MONEY!!!!!what to in a year and did so in less than a month
- Next by thread: Re: question
- Index(es):
Relevant Pages
|