Char: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Stubbed the article)
No edit summary
 
(21 intermediate revisions by 13 users not shown)
Line 1: Line 1:
[[category:variables]]
{{lang|Char}}
A '''character''' is, programmatically, one ASCII number value used to represent a keyboard character (a, x, 1, 6, ê). This variable is declared by the name char.
'''<code>char</code>''' is the amount of memory needed to store one [[W:ASCII|ASCII]] character. On architectures that Source supports, this is one [[W:byte|byte]] or eight [[W:bit|bit]]s.


This is a primitive C object.
<source lang=cpp>
char MyChar = 'T'; // single quote marks
</source>


[[String]]s are [[array]]s of '''Characters'''. These are used more often than characters are in the [[Source Engine]].
{{tip|Despite its name, there is no need for char to be used to store character data. It can also be employed simply as a means of storing one [[byte]] of data.}}


{{stub}}
Arrays of <code>char</code> or <code>[[wchar_t]]</code> are known as [[string]]s, and are used to store text. <code>char*</code> means a [[pointer]] to a char, which is almost always the start of a string.
 
In {{goldsrc|2}} and {{source|2}}, unsigned chars (0-255) are typedefed as {{codelink|byte}}.
 
== See also ==
* [[String]]
* <code>[[wchar_t]]</code>
 
[[Category:Variables]]
[[Category:Glossary]]

Latest revision as of 08:08, 3 May 2025

English (en)Deutsch (de)Русский (ru)Translate (Translate)

char is the amount of memory needed to store one ASCII character. On architectures that Source supports, this is one byte or eight bits.

char MyChar = 'T'; // single quote marks
Tip.pngTip:Despite its name, there is no need for char to be used to store character data. It can also be employed simply as a means of storing one byte of data.

Arrays of char or wchar_t are known as strings, and are used to store text. char* means a pointer to a char, which is almost always the start of a string.

In GoldSrc GoldSrc and Source Source, unsigned chars (0-255) are typedefed as byte.

See also