i want my program to be able to figure out if an input file
is one that was generated from it.
How can i use the magic number technique ?
Are there any other portable ways ?
TIA
i want my program to be able to figure out if an input file
is one that was generated from it.
How can i use the magic number technique ?
Are there any other portable ways ?
TIA
to boldy code where...
c++ imposes no structure on files it is entirely up to the programmer to structure his files exactly as he sees fit. So invent your own file format that will uniquely identify data files as belonging to your app.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
that's exactly what i want to do.
i know the structure should be of my choice,
but i'm asking for any common or popular ways to do so.
I just want the doc for them
to boldy code where...
One of my books told me ways to make magic numbers for files, I will look at it and post it when I get home this afternoon.
Help populate a c/c++ help irc channel
server: irc://irc.efnet.net
channel: #c
Much like graphics files or other common file formats, write a file header first. The first N bytes are this, the next N bytes are that... etc. Then add your data after it. You may want to jump over to Wotsit and look at a few file formats to get an idea of how things are commonly done.
Quzah.
Hope is the first step on the road to disappointment.
Well there is a simple way with structures:
Code:struct MyFileHeader { char ID[10]; ... .. };
ID could be any 10 characters. If the ID does not match your program's ID that it places in the string, it was not created by your program.
from Practicle C by, Steve OuallineOne method for choosing a magic number is choosing the first four letters of a program name(i.e, list) and then convert them to hexadecimal: 0x6C607374 then add 0x808080 to the number, producing the magic number of 0xECE0F3F4
this algorythm generates a magic number that is probably unique. The high bit is set on each byte to make the byte non-ANCII and avoid confusion between caps and ascii files
That is one way to go
Help populate a c/c++ help irc channel
server: irc://irc.efnet.net
channel: #c