What is the difference between "." and "->" in C language?

If you use ".", you only need to declare a structure. The format is structure type name + structure name. Then add "." and domain name to the structure name to refer to the domain of the structure. Because the memory of the structure is allocated automatically, just like using int a; If you use "->", you need to declare a pointer to the structure, and manually allocate a memory for the structure, and then assign the returned pointer to the declared structure pointer, so that you can use "->" to refer to the structure correctly. area. Otherwise, only pointer memory is allocated, not structure memory, and the required structure does not actually exist. In this case, using "->" reference will naturally make an error, because there is no structure, and there is no domain of the structure. "." I read directly as "of".


Just look at my comprehensive set of embedded C language learning tutorials, which include programming teaching, problem video explanations, 800 sets of complete sets and language teaching.a34fb8bf207d5e0e8e466562007851d6.jpeg

ac168e4cd56981e8a90c0e36db3a1852.jpeg

Guess you like

Origin blog.csdn.net/lz19zlun/article/details/132193384