Re: a string, a string array and character array



Rune Allnor wrote:
A "char array" is an array that contains numerical data of
type "char", that is numbers in the range -128 - 127.

I would have to dig for a while to find a computer language
which defined its "char" to be in the range -128 to 127.
For example, C doesn't: "char" has an implementation-defined
range that can be signed or unsigned; "char" in C has a certain
minimum span of values, but there is no maximum span of values
defined in C, and there -are- C implementations in which 'char'
is a 32 bit quantity (e.g., Cray, and some DSPs.)

Possibly one of the BASIC defined in terms of -128 to 127.
Defining char as unsigned is more common in computer languages.

In Matlab, as of somewhere around version 7.0 (I'd have to research
the exact version), individual char are stored as unsigned values from 0 to 65535.

char(65535) + 0

ans =

65535

char(65536) + 0
Warning: Out of range or non-integer values truncated during conversion to character.

ans =

65535


A "string" is an array that contains characters (letters)
instead of numbers. Certain operations work differently
with strings, like sorting. With strings, lowercase and
uppercase letters have different numerical values but the
same ordinal value (that is, "Abc" and "abc" are equivalent).

Urrr, I've never encountered that definition of "string" before.


In Matlab, a "string" is a common phrasing for a row vector of char.
A character array is an array of character type; if the array happens
to be two dimensional and the first dimension happens to be 1, then
the character array could also be called a "string". Two dimensional
arrays of characters are common in Matlab; the older convention in Matlab is
that if you need to pass in a list of strings, that you put them all
together in a two-dimensional array of characters whose width is the
width of the longest of the individual strings and with all of the shorter
lines right-padded with blanks.

Matlab also refers to "cell strings"; see the documentation
for cell2str().

--
..signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?
.



Relevant Pages

  • Re: Pointer
    ... require in input a pointer char: ... unsafe public static extern int OpenFile; ... What is it pointing to exactly, is it pointing to a "Unicode character" array or is it pointing to a "Single byte character" array or is it pointing to something else? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Pointer
    ... require in input a pointer char: ... unsafe public static extern int OpenFile; ... What is it pointing to exactly, is it pointing to a "Unicode character" array or is it ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: UTF-8 in char*
    ... >I am developing a vCard application which have to support UTF-8. ... >treat as NULL character in strlen? ... of type "unsigned char", as those will have at least 8 bits. ... strlensimply operates on an array ...
    (comp.lang.c)
  • Re: (*) and List Directed I/O
    ... character n of a character string could be accessed as b, ... of strings. ... || reference unless foo is declared as an array. ... || is a function reference. ...
    (comp.lang.fortran)
  • Re: Concatenate integer to string
    ... F2003 adds allocatable-length strings. ... Since a character with allocatable ... It seems that the deferred length has a special proparty, different from a deferred array size, in that the standard assignment operator will allocate the length. ...
    (comp.lang.fortran)