binary file reading

Hello Everybody,


How can i read mixed binary file?(for example binary file contains char and integers

length 2390
width 5000
and so on.
)

For binary file (2 byte per sample) i use

fread(buffer,sizeof(unsigned int),, file);

It gives me only integers
(2390
5000
and so on)

I want also to see
(length
width
and so on)


In davance
thanks
You need to clear on the file format before you can read/write it.
Hi kbw,

i can take signal from the digitizer in text or binary format.

i read easly text file with help fread or getline.
output is:
(
length 2390
width 5000
and so on.
)

But i read only integers in binary file.
outout is:
(
0 2390
0 5000
and so on
)
Gadir, Can you give us your attempt?
Hi Marie,

i use

1
2
3
4
5
6
7
8
9
10
unsigned short CAENt[148];

	inCAEN=fopen("wave0.dat","rb");

	for(int loop=0;loop<148;loop++) {
	
		fread(CAENt,sizeof(unsigned short),148,inCAEN);
		printf("%d %d\n",loop,CAENt[loop]);
	
	}
Topic archived. No new replies allowed.