#Strings in C
> If you state your question in English maybe I can help
Right, given that I can define a string in C as, for example, "ABCD" –
which a represents a pointer to the byte values 65, 66, 67, 68, 0 – I
would like to know if there is a convenient way of representing a string
which contains characters not directly accessible via the keyboard.
My original example was a string containing the byte values 155, 48, 32,
112, 0 which corresponds to the character '\x9B' followed by the
characters which comprise the C string "0 p"
Now, the problem is that if I try to define the string as "\x9B0 p" I find
that DICE objects to this, saying that I have too many digits. It takes
the '0' character as being a third digit to the \x9B specification, rather
than being the next valid ASCII character in the string.
So, for example, "\x9B p" is correctly translated by DICE into the
sequence 155, 32, 112, 0 whereas "\x9B0 p" becomes (after a warning) the
sequence 176, 32, 112, 0
Finally, my question is: what is the simplest, most convenient way to get
round the behaviour described above, so that I can enter arbitrary
characters (expressed as hexadecimal numbers) into arbitrary strings
(containing digits)?
One way that works is to convert the whole lot into hex or octal
characters. This, I find, is a pain, as my skills in ASCII -> octal
conversion are not good. Another way is to specify the whole lot on a
chracter-by-character basis, which is clumsy. Both these techniques are
too prone to errors.
…………………………………………………
While I have your attention, can I ask a second question on a totally
different topic? I would like to create a look-up table of alternating
pointers to strings and pointers to corresponding functions to be
executed. What is the syntax for specifying such a table? The overall
aim is to write a parser that looks at an input file, picks out a possible
keyword at the start of a line, looks it up in the table, and if found,
executes the appropriate function to interpret the remainder of the line.
Many thanks for any help.
Regards,
Shraddhan (via AP from Hertfordshire, England)