forked from freudenreichan/info2Praktikum-NeuronalesNetz
handle EOF / read errors better
This commit is contained in:
1 parent
d9bb6fd600
commit
cdc4a68824
1 file changed
+4
-3
@@ -45,15 +45,16 @@ ending_openAndCheck:
|
||||
|
||||
static int getUShort(FILE **fd, unsigned short *bilderAnzahl)
|
||||
{
|
||||
if (!fread(bilderAnzahl, (size_t)sizeof(unsigned short), 1, *fd))
|
||||
size_t bytes = 0;
|
||||
if (!(bytes = fread(bilderAnzahl, (size_t)sizeof(unsigned short), 1, *fd)) || bytes != 1)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int getUChar(FILE **fd, unsigned char *dest)
|
||||
{
|
||||
// unsigned short lab = '0';
|
||||
if (!fread(dest, sizeof(*dest), 1, *fd))
|
||||
size_t bytes = 0;
|
||||
if (!(bytes = fread(dest, sizeof(*dest), 1, *fd)) || bytes != 1)
|
||||
return 1;
|
||||
// printf("Read Label: %d\n", *dest);
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user