reading a file in hex

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2007
Posts: 13
Reputation: Daco is an unknown quantity at this point 
Solved Threads: 0
Daco Daco is offline Offline
Newbie Poster

reading a file in hex

 
0
  #1
Oct 13th, 2008
hey there everyone
i was working on a program of mine when that should read the file in hex and display the value of a certain hex address (0x000068FC as example).

but i have no clue where to begin except that ppl say it should work with fseek & fread
ive tried but i can't seem to work with it.
anyone might wanna help me with this?

thx
Daco
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,350
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1462
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: reading a file in hex

 
0
  #2
Oct 13th, 2008
post what you have tried. And post an example data file.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 13
Reputation: Daco is an unknown quantity at this point 
Solved Threads: 0
Daco Daco is offline Offline
Newbie Poster

Re: reading a file in hex

 
0
  #3
Oct 13th, 2008
i didn't post code cause i knew i was totally wrong >_<

  1. FILE *pFile;
  2. char* buffer;
  3. pFile = fopen("file.raw","rb");
  4. //ill use the example address from original post
  5. if(fseek(pFile, 0x000068FC, SEEK_SET))
  6. {
  7. //the 2 means to read 2 bytes right?
  8. fread(buffer,1,2,pFile);
  9. fread(memory_card_content, 1, memory_card_size, pFile);
  10. }
  11. // final check to see what value buffer contains using command PanicAlert
  12. PanicAlert("buffer = %x or %c",buffer,buffer");
  13.  
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,350
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1462
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: reading a file in hex

 
0
  #4
Oct 13th, 2008
Also please post actual text of the assignment, not how you interpreted it.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 13
Reputation: Daco is an unknown quantity at this point 
Solved Threads: 0
Daco Daco is offline Offline
Newbie Poster

Re: reading a file in hex

 
0
  #5
Oct 14th, 2008
this is the file it should read in the code.
if that is what you mean
Last edited by Daco; Oct 14th, 2008 at 5:57 am.
Attached Files
File Type: txt file.txt (2.00 MB, 7 views)
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,350
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1462
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: reading a file in hex

 
0
  #6
Oct 14th, 2008
That wasn't what I meant -- There must have been more the the instructions your teacher gave you what what you posted because what you posted doesn't make any sense. Post exactly the words given to you.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 13
Reputation: Daco is an unknown quantity at this point 
Solved Threads: 0
Daco Daco is offline Offline
Newbie Poster

Re: reading a file in hex

 
0
  #7
Oct 14th, 2008
i dont follow coding classes. im doing this on my own.

ill explain all over again
when you hex edit a file you have a certain value on a certain address
for example you have value 04 on address 0x000068FC
my question was how do i check if hex address 0x000068FC has 04 as value
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,350
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1462
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: reading a file in hex

 
0
  #8
Oct 14th, 2008
where did you get that address from? 68FCH == 26876 decimal. If that's the byte offset in the file where that value is found, then you should be able to just seek to that position and read that byte.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC