Thank you for your reply!
I understand what you mean about the "pages of the book" now. Still when I try to print to screen what has been read into the buffers I get strange results except for the normal "chars".
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void main()
{
// declarations
FILE *file_in;
char inpfile[200], name_file_out[210], *raw_data_file_name, *site_name;
unsigned char *header_version, *data_format;
unsigned long *header_size, *site_id;
printf(" Input binary file\n");
scanf("%s", &inpfile);
strcpy(name_file_out, "out_");
strcat(name_file_out, inpfile);
printf(" Output file with amplitude: %s\n", name_file_out);
if (!(file_in = fopen (inpfile, "rb")))
{
printf("\nCannot open the input file - image file\n");
exit(0);
}
/********** allocations ****************/
header_version = (unsigned char *) malloc (1*sizeof(unsigned char));
header_size = (unsigned long *) calloc (1,sizeof(unsigned long));
data_format = (unsigned char *) malloc (1*sizeof(unsigned char));
raw_data_file_name = (char *) malloc (90*sizeof(char));
site_name = (char *) malloc (30*sizeof(char));
site_id = (unsigned long *) calloc (4,sizeof(unsigned long));
/********** read binary ****************/
fread((unsigned char *) header_version, sizeof(unsigned char), 1, file_in);
fread((unsigned long *) header_size, sizeof(unsigned long), 1, file_in);
fread((unsigned char *) data_format, sizeof(unsigned char), 1, file_in);
fread((char *) raw_data_file_name, sizeof(char), 80, file_in);
fread((char *) site_name, sizeof(char), 24, file_in);
fread((unsigned long *) site_id, sizeof(unsigned long), 1, file_in);
/********** print **************/
printf("%s\n", header_version);
printf("%ld\n", header_size);
printf("%s\n", data_format);
printf("%s\n", raw_data_file_name);
printf("%s\n", site_name);
printf("%ld\n", site_id);
fclose(file_in);
}
the output is:
Input binary file
a
Output file with amplitude: out_a
☻²²²²
4399040
♥²²²²
000001 - 2008.07.25 - 16.57.28 - nch3
══════════²²²²
nch3 ══════²²²²
4398704
Press any key to continue