简体   繁体   中英

Clarification about a particular struct definition in C

I found this structure in the slides of my professor:

struct point{
      int x;
      int y;
} p;

What does p mean? So far I used only the classical struct like this:

struct point{
      int x;
      int y;
};
struct point{
      int x;
      int y;
} p;

defines a variable p of type struct point

it is same as

struct point{
      int x;
      int y;
};
struct point p;
struct point{
    int a;
    int b;
}p;

This is the same as using struct point p

When we use typedef struct p as in

typedef struct point{
    int a;
    int b;
}p;

We can use p to declare a structure pointer or structure variable later on

To create a structure pointer p *abc

To create a structure variable p xyz

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM