The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > C / C++


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Tags: , ,

Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 04-09-2008, 05:54 AM
MrPickle's Avatar
MrPickle MrPickle is offline
PT Admin
Join Date: Nov 2007
Location: England, Lincolnshire
Posts: 332
iTrader: (0)
MrPickle is a jewel in the roughMrPickle is a jewel in the roughMrPickle is a jewel in the rough
Reading hexidecimal files

I am trying to read some data from a file but the file is in Hexadecimal and I'm really stumped.

I need to read "chunks" and at the beginning of each chunk there's a sort of header so that you can tell what sort of data the chunk holds.

I am completely clueless as to how to read hex because if you look at the file with a text editor it's a load of twaddle but then when I read it with a Hex editor it's all pretty understandable :3

Also, why do I often see hexadecimal accompanied by a 0x at the front; eg
0x4D4D.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 05:17 PM
Lee's Avatar
Lee Lee is offline
PT Staff*
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: Blackpool, UK
Posts: 616
iTrader: (0)
Lee is just really niceLee is just really niceLee is just really niceLee is just really nice
I just did a quick search and saw on wikipedia, if you go to:
Hexadecimal - Wikipedia, the free encyclopedia

The find:
Common Patterns and humor

There's a little on it there but whether its want you want i don't know? Seems to make sense to me.

Quote:
The first three are interpreted as multiplication, but in the last, "0x" signals Hexadecimal interpretation of 12, which is 18.
Reply With Quote
The Following User Says Thank You to Lee For This Useful Post:
MrPickle (04-10-2008)
  #3 (permalink)  
Old 04-09-2008, 07:13 PM
ccoonen ccoonen is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Location: Wisconsin
Posts: 317
iTrader: (0)
ccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished road
That's hex - 0xFFFFFF = White, 0x000000 = Black
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 03:49 AM
MrPickle's Avatar
MrPickle MrPickle is offline
PT Admin
Join Date: Nov 2007
Location: England, Lincolnshire
Posts: 332
iTrader: (0)
MrPickle is a jewel in the roughMrPickle is a jewel in the roughMrPickle is a jewel in the rough
Hex isn't just colours I thought that too until a couple of months back when I was corrected.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #5 (permalink)  
Old 04-10-2008, 04:01 AM
Bench Bench is offline
Full Programmer
Join Date: Jul 2007
Location: UK
Posts: 116
iTrader: (0)
Bench is on a distinguished roadBench is on a distinguished roadBench is on a distinguished roadBench is on a distinguished roadBench is on a distinguished road
There's no such thing as a hexadecimal file - the hex editor is just showing you a hexadecimal representation of your data, which, like all electronic data, is stored in a binary form (The 0x prefix is a form of notation to denote a number as being in hex/base-16 ). You can either read a file as raw data, one byte at a time, or as text.

If opening it up in a text editor looks like nonsense, then you probably want to read it byte(s) at-a-time, into an unsigned char or array of unsigned char (Look up binary I/O in C++).
- What you do with the data after that is entirely up to you - it requires precise knowledge of the format within which the file has data stored to make the data meaningful, and depends how you wish the data to be stored & represented after you've read it from the file.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 06:46 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50