Questions about struct definitions in C

Updated on technology 2024-03-26
4 answers
  1. Anonymous users2024-02-07

    I've seen questions like this, and I don't understand what you mean, but I think it's like this, structab; I hit ... where you can add definitions of all data forms, e.g., int

    a;char

    a[10];Wait a minute;

    and b represents the variable name. It's like int

    A is just a variable identifier, and it is a struct variable. When you use typedef, it represents an enumeration type, which functions just like a macro definition, and uses it in the following way:

    First of all. Write out the type of variable you want to represent. For example: INTA; Then add typedef, typedefinta in front of int; Then put the variable name a

    Change to the representation you want to use, such as:

    pp;Now it becomes.

    typedef

    intpp;

    When you want to define other variables as int, you can define them like this. ppb;

    B here is the variable name. Note that enumerating types does not create new variable types, but rather a substitute. I'll give you an example.

    typedef

    structa{int

    s;char

    p[10];

    num;num

    n;That's when n is.

    struct

    A type struct variable. I don't know if you know ...

  2. Anonymous users2024-02-06

    bstruct

    The name of the structure. A list of variable names.

    struct

    The name of the structure. A list of member descriptions.

  3. Anonymous users2024-02-05

    The C structure is a collection of data similar to a business card, which can be understood as a special composite "data type" defined by the user, and in this composite "data type" can contain a variety of basic data types, and we can operate it as a whole.

    C uses: A reference to a struct array is in principle the same as a reference to a struct variable. It's just that there are multiple struct variables in the struct array, and we just need to use the for loop to use the elements in the struct array one by one.

    The meaning of the structure.

    A struct describes the explanatory meaning of a piece of memory.

    For example, if there is a data 3 in memory, if it is only used as a positive integer, then its meaning is positive integer 3, and if 3 in memory is used as the 3rd power of 2, then the meaning of 3 is exponential 3. A struct describes the meaning of the data in a piece of memory.

  4. Anonymous users2024-02-04

    1. Definition of structureA struct is a collection of one or more pieces of data, which can be of different types, and the struct is equivalent toarrayupgrades. If we want to count the grades of students in a class, and the grades are of the float type, we can use the gradesarrayDeposit. However, if you want to count the name, gender, and grades of students in a class, the name is a string, the age is an integer, and the grade is a decimal, because the data type is different, it obviously cannot be usedarrayDeposit.

    To solve this problem, another type of construct data is given in C - struct. It can store multiple data types of the same object together.

    2. Definition formWay 1, place the struct variable directly at the tail end of the struct.

    struct structure name; Zhang San male scored 100Fourth, the use of structureTake the example of Mode 2 as an example.

    struct student ;Zhang San Male Score 100*** Use***

    zhangsan. score =60;Assign Zhang San's score to 60

Related questions
9 answers2024-03-26

Scope. You static char *chh;

static char *ch1;Although the address pointed to by the two pointers does not change, have you ever wondered whether the memory address they point to has been released, char chc[10]; It's local, the function is out, the lifecycle is over, and you're trying to access it with a pointer in void times(). >>>More

6 answers2024-03-26

Define the struct:

typedef struct _legaladdress_{ >>>More

5 answers2024-03-26

These are not macro definitions, these are file containments. >>>More

6 answers2024-03-26

Understand the following rules: 1) Overloading an operator does not change the priority of the operator. >>>More

9 answers2024-03-26

However, it is clear that this is problematic because variable a is not assigned at all. >>>More