Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/10/2010, 06:08
g3rm4n
 
Fecha de Ingreso: julio-2010
Mensajes: 46
Antigüedad: 13 años, 9 meses
Puntos: 0
Respuesta: leer bloques de bytes y comprarlos

Veamos si esto te sirve... Es para hacer una entrada/salida cruda (en este caso para leer) a un archivo binario:

Código C:
Ver original
  1. FILE* pFile = fopen(path, "rb");
  2.     if (pFile == NULL) {
  3.         printf("Error al intentar abrir el archivo. \n");
  4.         return NULL;
  5.     } else {
  6.  
  7.         int start = ftell(pFile);
  8.         fseek(pFile, 0, SEEK_END);
  9.         int end = ftell(pFile);
  10.         rewind(pFile);
  11.  
  12.         int size = end - start;
  13.  
  14.         unsigned char* data = (unsigned char*) malloc(size);
  15.         fread(data, 1, size, pFile);
  16.  
  17.         // Más código...
  18.  
  19.         fclose(pFile);
  20.     }
  21. }

Saludos!