?
ich mag selbstgespräche zwar nicht, aber hier nochmal die lösung, da es endlich geklappt hat
void ReadSourceFile( void ){
int i;
FILE * pFile;
long lSize;
unsigned char * buffer;
size_t result;
pFile = fopen ( "RT-Modul.bin" , "rb" );
if (pFile==NULL) {fputs ("File error",stderr); exit (1);}
// obtain file size:
fseek (pFile , 0 , SEEK_END);
lSize = ftell (pFile);
rewind (pFile);
// allocate memory to contain the whole file:
buffer = (unsigned char*) malloc (sizeof(unsigned char)*lSize);
if (buffer == NULL) {fputs ("Memory error",stderr); exit (2);}
// copy the file into the buffer:
result = fread (buffer,1,lSize,pFile);
if (result != lSize) {fputs ("Reading error",stderr); exit (3);}
printf("l-size: %d result:%d\n\n",lSize,result);
for(i=0;i<lSize;i++)
printf("%02X ", buffer[i]);
fclose (pFile);
free (buffer);
}
wieso sagt mir auch keiner, dass alles schon in buffer drinsteht ^^