Hi guys,
I am trying to write a code to read from a .dat file and then store its
contents in an array of word format so that it can be used in a another
funciton. But have no clue how to go about it can cany one help. The contents
are in the following format.

0A, 78
2B, 93
03, FE

// Skip the line when starts with double forward slashes
00, 10
04, 40
// Skip the line when starts with double forward slashes
// 56, A0

23, 1F
..can any one help !!

Recommended Answers

All 6 Replies

are those hex values? Are you certain there is a comma between words? e.x. 0010 and 0440? One way to do it if with int ival; fscanf(%x", &ival);

Yes they are all hex values.
Hex followed by a coma followed by a space and then a hex value
. Can you help .
Thank you

And I am trying to read and store these hex values In two word arrays and use them in a function .

The Dragon gave you a major clue. Try reading about fscanf() and try some things. Testing is the best way to learn.

You may also use file handling methods to input from dat file.
See this.

Hey Thanks guys. It sure helped a lot !! you guys are awesome !!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.