fread gets more chars than i ask in c while working with binary file : <p>i'm a beginner in C and in my internship i have to work with a binary file and i must read the information in a binary file, one information at a time, </p>

<pre><code>int main()
{
FILE *ptr=fopen("C:\\Users\\Workstation\\Desktop\\TEST.MAILO","rb");

char header[65];
char CRLF[3];
char first40[41];
char rio[33];
char date_capture[9];


if (ptr==NULL){
    printf("Erreur");
exit(EXIT_FAILURE);
}

fread(header, sizeof(char), 64, ptr);
fread(CRLF, sizeof(char), 2, ptr);
fread(first40,sizeof(char),40,ptr);
fread(rio,sizeof(char),32,ptr);
fread(date_capture,sizeof(char),8,ptr);

printf("%s%s",header,CRLF);
printf("%s|||%s|||",first40,rio);
printf("%s||",date_capture);

return 0;
}
</code></pre>

<p>the problem is that in the last variable "date_capture" i ask for 8chars for the date but it gets more than 8</p>

<p><strong>EIMG05050120170609007MADIMC0500014
0310000032050810011010358897200120007780|||007MAD00901020170609000109259941|||20170608■007MAD00901020170609000109259941||</strong></p>

<p>it is supposed to print only 20170608 without the rest <strong>■007MAD00901020170609000109259941||</strong> 
please help me i looked everywhere i haven't found any problem like this. THANK YOU</p>
