简体   繁体   English

以下代码的含义是什么?

[英]What is the meaning of the following code?

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"};

The code is invalid.代码无效。 The string literals are of type char[N] (where N is the length of each string literal).字符串文字是char[N]类型(其中N是每个字符串文字的长度)。 These are implicitly convertible to char* but not to unsigned char* .这些可以隐式转换为char*但不能转换为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.如果display_screenconst char*[]而不是const unsigned char*[] ,这会将display_screen声明为const char*数组,数组中的指针指向初始化程序中列出的字符串文字。

Besides the signedness issue that James mentions, this defines an array of strings.除了 James 提到的签名问题之外,这还定义了一个字符串数组。 The "\\xfe" at the beginning translate to hexadecimal value 0xfe and the "\\35" translates to octal 035 .开头的"\\xfe"转换为十六进制值0xfe"\\35"转换为八进制值035 The interpretation of these values is dependent of your platform.这些值的解释取决于您的平台。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM