" is a whole in C language. This symbol is used to point to the pointer to the sub-data in the structure, and the sub-data can be taken out. To use it, first define a structure in C language; then declare a pointer pointing to This structure; finally use this symbol to point to the corresponding sub-data name."/> " is a whole in C language. This symbol is used to point to the pointer to the sub-data in the structure, and the sub-data can be taken out. To use it, first define a structure in C language; then declare a pointer pointing to This structure; finally use this symbol to point to the corresponding sub-data name.">

Home  >  Article  >  Backend Development  >  What does '->' mean in C language?

What does '->' mean in C language?

Guanhui
GuanhuiOriginal
2020-06-04 16:07:5430523browse

What does '->' mean in C language?

What does "->" mean in C language?

"->" is a whole in C language. This symbol is used to point to the pointer to the sub-data in the structure, and the sub-data can be taken out. The usage method is first in C language Define a structure; then declare a pointer pointing to the structure; and finally use the symbol to point to the corresponding sub-data name.

Usage examples

/*定义结构体*/
struct Data
{
   int a,b,c;
};
/*定义结构体指针*/              
struct Data * p;
/*声明变量A*/
struct Data A = {1,2,3};
/*声明一个变量x*/
int x;
/*让p指向A*/
p = &A ; 
/*这句话的意思就是取出p所指向的结构体中包含的数据项a赋值给x*/
x = p->a;
/*由于此时p指向A,因而 p->a == A.a,也就是1*/

Recommended tutorial: "C#"

The above is the detailed content of What does '->' mean in C language?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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