Questions about struct array data entry in the program

Updated on technology 2024-02-09
9 answers
  1. Anonymous users2024-02-05

    This can be agreed upon by yourself. For example, when entering a convention, a character space is used to indicate that the item does not need to be entered.

    Then, when the program finds that the input character is a space, set the value of the item to a default value, and then skip to the next data processing.

    As long as the convention's special characters don't appear when you enter data for other projects, that's fine.

  2. Anonymous users2024-02-04

    Blank data is discarded directly! Such as encountering" a"Don't use it, just while(a[i]!='a'That's it.

  3. Anonymous users2024-02-03

    Input method: 5 data are entered at a time for(i=0; In the IC language, a struct is a data structure, which is a type of aggregate data type in the C language. Structs can be declared as variables, pointers, arrays, etc., to implement more complex data structures.

    A struct is also a collection of elements called members of a struct, and these members can be of different types, and members are usually accessed by name.

    Structural roles.

    Structs are the same as other basic data types, such as int and char, except that structs can be made into the data type you want. for easy future use. In real projects, structures exist in large numbers.

    Developers often use structs to encapsulate properties to form new types. Due to the simplicity of the internal programs in C, developers often use structs to create new "properties" with the aim of simplifying operations.

    The role of structs in functions is not simple, but their main role is encapsulation. The benefit of encapsulation is that it can be reused. So that the user doesn't have to care about what it is, just use it according to the definition.

    The above content reference: Encyclopedia - Structure.

  4. Anonymous users2024-02-02

    scanf("%d%s%d%d%d

    5 pieces of data were entered at once.

    for(i=0;i loop twice.

    So you only need to enter 10 pieces of data, no matter how you enter it, please see **:

  5. Anonymous users2024-02-01

    1. If you enter from a standard input, only enter the members of each struct object one by one. If you import from a file, you can read the entire object directly with the fread function.

    2. Example: include

    struct student

    void main()

    printf("Typing is complete");

    for(i=0;i<5;i++)

    print(stu[i]);

    void print(struct student stu)

  6. Anonymous users2024-01-31

    Don't wrap after the last %d, and remove the spaces.

  7. Anonymous users2024-01-30

    scanf("%d%s%d%d%d%d all the spaces after it!

  8. Anonymous users2024-01-29

    u computer memory open kneeling, it is difficult to separate, I feel that the dark green, to Jinan just seen.

  9. Anonymous users2024-01-28

    01Define an array of structs.

    1. A structure variable can store a set of related data (such as a student's student number.

    name, grades, and other data). If you have 10 students' data that needs to be calculated, you should obviously use an array, which is an array of structs.

    2. The difference between struct arrays and numeric arrays introduced earlier is that each array element is a struct type of data, and they all include individual member items.

    3. Define the general return form of the array of structs.

    1) struct structure name.

    member table column}array name [array length];

    2) Declare a struct type (e.g. struct person) and then define the struct array with this type: struct type array name [array length];

    4. The form of initializing the struct array is to add a hail pose after the definition of the array: =;

    5. Initialize when defining the structure array, for the sake of clarity, wrap each student's information with a pair of curly braces, which is more convenient to read and check, especially when the amount of data is large, which is beneficial.

Related questions
6 answers2024-02-09

Define the struct:

typedef struct _legaladdress_{ >>>More

16 answers2024-02-09

Just o(n) scans it once, millions of arrays are not big, and c can be opened so big for global variables. >>>More

9 answers2024-02-09

Design and development proposals.

Serial number: Serial number: >>>More

13 answers2024-02-09

2. In the second step, if you want to get the brand of the phone or tool you are debugging, you can use brand. >>>More

14 answers2024-02-09

Generally, there are two materials for ribbons, one is polyester and the other is silk. >>>More