|
From: Ioannis V. <no...@ho...> - 2003-02-22 05:34:04
|
-------Original Message-------=0D
=0D
From: airam=0D
Date: =D3=DC=E2=E2=E1=F4=EF, 22 =D6=E5=E2=F1=EF=F5=DC=F1=E9=EF=F2 2003 12=
:19:18 =F0=EC=0D
To: dev...@li...=0D
Subject: [Dev-C++] fread=0D
=0D
Hi!!!!!!=0D
i want to read a file every 4bytes=0D
and after printf=0D
this is the code but doesn't work!!=0D
=0D
The above "every 4 bytes" of yours is not clear. I assume you mean "read =
to
an unsigned int leaving 4 bytes space between two reads in text mode=0D
=0D
=0D
=0D
#include <stdio.h>=0D
=0D
/* For EXIT_FAILURE */=0D
#include <stdlib.h>=0D
=0D
int main()=0D
{=0D
unsigned int j;=0D
size_t input;=0D
=0D
=0D
FILE *f;=0D
=0D
f=3Dfopen("filename","r");=0D
=0D
if (!f)=0D
return EXIT_FAILURE;=0D
=0D
/* or do-while(1) */=0D
while(1)=0D
{=0D
input=3Dfread(&j,sizeof(unsigned int),2,f);=0D
=0D
if(input<2)=0D
{=0D
fclose(f);=0D
return 0;=0D
}=0D
=0D
printf("%u\n", j);=0D
=0D
fseek(f,4,SEEK_CUR);=0D
=0D
}=0D
=0D
/* Required in C90 */=0D
return 0;=0D
=0D
}=0D
=20 |