Home > Backend Development > C#.Net Tutorial > What does '->' mean in C language?

What does '->' mean in C language?

Guanhui
Release: 2020-06-04 16:07:54
Original
30541 people have browsed it

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*/
Copy after login

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!

Related labels:
c
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