IGNORING COMMENTS IN SOMELINES OF TEXT FILE IN FSCANF

hi i have a hex file like below format

Addr1 data1 //comment

i want to use addr data or each line and load into memory for that i have written a code something like this.

while (!$feof(addr_data_file)) begin
     scan_file = $fscanf(addr_data_file, "%h %h", addr,data);
     agent.slave[0].slave_mem.write(addr, data); // write data to slave memory
     read_data = agent.slave[0].slave_mem.read(addr);  // read if the data is written in to the memory or not
     $display("my data read through backdoor addr= %0h : data= %0h",addr, read_data);
end

its only loading first data again and again. i know the issue is coming because of comments because when i remove them its working fine but i need to keep the comments. any solution for the same ??

In reply to pawan:

if you have the comment for each line, try this

scan_file = $fscanf(addr_data_file, "%h %h %s\n", addr,data,comment);

In reply to javatea:

Actually i have comment in somelines not all lines…

In reply to pawan:

$fscanf is good for the statndard format.
in your case, you might use $fgets to get every line and do some parse to see if //comment inside.
I think it much easier to sed input file then going thru it. :p
referring to $system if you like

In reply to pawan:
Use $fgets to read a line of your file into a string, and then use $sscanf to parse each string. Do check the return codes from each call.