Reputation: 77
Could anyone tell me what is the meaning of the following code :
unsigned char const *display_screen[] = {
"\xfeXEPC Main Menu:\n\35System Status\n System Settings\n Access Control",
"\xfeXEPC Main Menu:\n System Status \n\35System Settings\n Access Control",
"\xfeXEPC Main Menu:\n System Status \n System Settings\n\35Access Control",
"\xfeXEPC Main Menu:\n\35Configuration\n Op.Programming\n Event Log ",
"\xfeXEPC Main Menu:\n Configuration\n\35Op.Programming\n Event Log ",
"\xfeXEPC Main Menu:\n Configuration\n Op.Programming\n\35Event Log ",
"\xfeXEPC Main Menu:\n\35History ",
"\xfeXEPC Main Menu:\n"};
Upvotes: 0
Views: 269
Reputation: 355307
The code is invalid. The string literals are of type char[N]
(where N
is the length of each string literal). These are implicitly convertible to char*
but not to unsigned char*
. Since the code is invalid, it doesn't have any meaning. :-)
If display_screen
was a const char*[]
instead of a const unsigned char*[]
, this would declare display_screen
as an array of const char*
with the pointers in the array pointing to the string literals listed in the initializer.
Upvotes: 3
Reputation: 78973
Besides the signedness issue that James mentions, this defines an array of strings. The "\xfe"
at the beginning translate to hexadecimal value 0xfe
and the "\35"
translates to octal 035
. The interpretation of these values is dependent of your platform.
Upvotes: 0