Home > Common Problem > What is stored in the string pointer variable is

What is stored in the string pointer variable is

(*-*)浩
Release: 2019-07-29 13:06:07
Original
7473 people have browsed it

Strings are mainly used for programming, here is a little addition: strings are similar to character arrays in storage, so each of its individual elements can be extracted, such as s="abcdefghij", Then s[1]="b", s[9]="j", and the zero position of the string is its length, such as s[0]=10, which can provide us with a lot of convenience, such as high precision During operation, each bit can be converted into a number and stored in an array.

What is stored in the string pointer variable is

A string or string (String) is a string of characters composed of numbers, letters, and underscores. Generally recorded as s="a1a2···an" (n>=0). (Recommended learning: PHP video tutorial)

It is a data type that represents text in programming languages. In programming, a string is a continuous sequence of symbols or values, such as a symbol string (a string of characters) or a binary digit string (a string of binary digits).

C language handles string constants as character arrays, and a character array is opened in the memory to store the string constants. Initializing a character pointer variable actually assigns the address of the first element of the string (that is, the address of the first element of the character array that stores the string) to string.

The string pointer variable stores the first address of the string.

Usually the entire string is used as the operation object, such as: finding a substring in the string, obtaining a substring, inserting a substring at a certain position in the string, and deleting a substring. wait. The necessary and sufficient conditions for two strings to be equal are: the lengths are equal, and the characters at each corresponding position are equal.

Suppose p and q are two strings. The operation of finding the position where q first appears in p is called pattern matching. The two most basic storage methods of strings are sequential storage and linked storage.

The string data type is a data type modeled on the idea of ​​a formal string. String is a very important and useful data type that can be implemented in almost all programming languages.

They are available as primitive types in some languages ​​and as composite types in others.

The syntax of most high-level languages ​​allows instances of the string data type to be represented by strings, usually quoted in some way; such metastrings are called "texts" or "string literals".

Although formal strings can be of arbitrary (but finite) length, the length of strings in real languages ​​is often limited to an artificial maximum.

Generally speaking, there are two types of string data types: "fixed-length string", which has a fixed maximum length and uses the same amount of memory regardless of whether the maximum value is reached; and "variable-length strings", whose length is not arbitrarily fixed and uses a variable amount of memory depending on the actual size.

Most strings in modern programming languages ​​are variable-length strings. Despite the name, all variable-length strings have a limit on their length, which generally depends only on the amount of memory available.

For more PHP related technical articles, please visit the PHP Graphic Tutorial column to learn!

The above is the detailed content of What is stored in the string pointer variable is. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template