I have a requirement where I have to ready a binary file and search for a particular address given by user and store the hex value of corresponding address in an array.
I have a file like "39059921.HA". Which i have to read on a button click.
I have opened the file in hex viewer and the inside content are like below
Block 0 Strarts at:0x 0 Ends at: 0x4319 (Length:0x431A=17178)
00000000: 03 01 00 02 04 00 55 50 41 00 00 00 00 00 00 00 ......UPA.....
00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................
00000020: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF .................
00000030: 66 65 74 79 00 00 00 00 00 00 00 00 CD 38 1A D1 .fety........
-------
-------
I tried reading the file like normal text file but i am getting some junk value.
QFile file("39059921.HA");
{
return;
}
while(!stream.atEnd())
{
qDebug()<<"data"<<line;
}
file.close();
output:-I get the output like below
data""—¶GÃEÃk|‘s‰žÃ*¥òm[ˆ8êܳ$7¢,HYNܾlFTÛ/õêÃâlÂ¥Bóîä1©»0*Â¢ÃÆ’©è~Êßl«Ê2<ˆWXˆ³8{Èà ÂIÃ…@"
data"&ÓûcVp„êp1¡Çø–ÚÂñT77â€(/•´„ŸÎµ°©¯â€9·|ÞmJ"5²ŒB¡ó†˜NWeB(¯e£Â÷•ˆ^Ó$Ã’o›ùt{€"“Ts²–)‡hexText "ppÀhexText "pqÆ pˆà p•ÂÃx‡õphà "
QFile file("39059921.HA");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
return;
}
QTextStream stream(&file);
while(!stream.atEnd())
{
QString line = stream.readLine();
qDebug()<<"data"<<line;
}
file.close();
output:-I get the output like below
data""—¶GÃEÃk|‘s‰žÃ*¥òm[ˆ8êܳ$7¢,HYNܾlFTÛ/õêÃâlÂ¥Bóîä1©»0*Â¢ÃÆ’©è~Êßl«Ê2<ˆWXˆ³8{Èà ÂIÃ…@"
data"&ÓûcVp„êp1¡Çø–ÚÂñT77â€(/•´„ŸÎµ°©¯â€9·|ÞmJ"5²ŒB¡ó†˜NWeB(¯e£Â÷•ˆ^Ó$Ã’o›ùt{€"“Ts²–)‡hexText "ppÀhexText "pqÆ pˆà p•ÂÃx‡õphà "
To copy to clipboard, switch view to plain text mode
How can I read the above and search for a particular address
Bookmarks