How can i extract strings and values using sscanf

In reply to cgales:

Hi cgales,
Sure, let me explain my requirement.

i have a file which would contain the below format:
-sys.hir00.mbo01.fir_hid.nn0.hero0.nd.gb.crappy.REG0 0x00000149
// sys.hir00.mbo01.fir_hid.nn0.hero0.nd.gb.crappy.REG0.FIELD [2:0] 0x1
// sys.hir00.mbo01.fir_hid.nn0.hero0.nd.gb.crappy.REG0.FIELD1 [5:3] 0x1
// sys.hir00.mbo01.fir_hid.nn0.hero0.nd.gb.crappy.REG0.FIELD2 [7:6] 0x1
// sys.hir00.mbo01.fir_hid.nn0.hero0.nd.gb.crappy.REG0.FIELD3 [31:8] 0x1

now my requirement is to read this file and get the value of either the REG0 which is 0x00000149 or if i want i should be able to get FIELD1 value which 0x1.

i would simply call from my function as GetValue(“path”)

Ex: GetValue(“sys.hir00.mbo01.fir_hid.nn0.hero0.nd.gb.crappy.REG0”); → this should return the entire value of the register which is 0x00000149
or
GetValue(“sys.hir00.mbo01.fir_hid.nn0.hero0.nd.gb.crappy.REG0.FIELD1”); → this should return the value of the field which is 0x1.

Currently i am able to open the file and match the string in the file and get the entire line, but not able to get the value of the reg or field.

Hope i have explained it well.

let me know if need more details?

regards
Srikanth