MQL4|Character Type (char)

※記事内に広告を含む場合があります。

Usage The character type (char) is used to represent a single character. Unlike other programming languages, MQL4 uses the int type to represent characters. This is because characters are treated as numerical values internally in MQL4.

Size The size of the character type is 4 bytes. This memory size is necessary to represent the character as a numerical value.

Range of Values The range of values for the character type is from 0 to 255. This is based on ASCII codes, allowing the representation of alphanumeric characters and symbols.

Example of Use Below is an example of using the character type. In this example, characters are treated as numerical values to determine whether a specific character has been input and to output a message accordingly.

void OnStart() {
    // Define characters as numerical values
    int charA = 'A';
    int charB = 'B';

    // Determine if a specific character has been input
    if (charA == 65) {
        Print("Character A has been input.");
    }

    if (charB == 66) {
        Print("Character B has been input.");
    }
}

In this code, the character type is used in the following steps:

  1. Characters ‘A’ and ‘B’ are defined as their respective ASCII codes, 65 and 66.
  2. The if statement is used to determine if character ‘A’ has been input. Since the ASCII code for ‘A’ is 65, a message is output if charA equals 65.
  3. Similarly, the if statement is used to determine if character ‘B’ has been input, and a message is output if charB equals 66.

Thus, the character type is used to treat single characters as numerical values. It is useful in scenarios where character manipulation or determination is required.

※記事内に広告を含む場合があります。
ベアちゃん@東京シストレ: One of Japan's oldest MetaTrader FX automated trading developers 🔧. With over 15 years of professional experience, he boasts achievements such as winning first place in the Tradency Tournament '15 🥇 and being the runner-up in the 3rd EA-1 Grand Prix 🥈. He has also appeared on Radio Nikkei and is currently active as an executive of Trilogy Corporation (a registered investment advisory and agency business) [Registration number: 372, Director of the Kinki Finance Bureau, Ministry of Finance]. To join the board of Trilogy Corporation, he underwent a rigorous personal examination by the Kinki Finance Bureau, and his name is now registered with the Kinki Finance Bureau. Becoming an executive officer of a registered investment advisory and agency business requires passing this stringent personal examination. Utilizing his extensive knowledge as a former senior design engineer, he provides insights into the development of high-performance Expert Advisors (EAs), the latest trading technologies, and market analysis. He delivers professional strategies and tips to traders aiming to optimize their FX trading and maximize profits.

This website uses cookies.