Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Struct with Arrays and Other Structs | Advanced Structs Usage
C Structs
course content

Contenido del Curso

C Structs

C Structs

1. Introduction to Structs
2. Pointers and Structs
3. Structs and Memory
4. Advanced Structs Usage
5. Implementing Data Structures

Struct with Arrays and Other Structs

In some structures there is a need to use an entire array of nested structures to describe more complex objects.

To get access to the required array element of a nested structure, you must:

  1. Refer to the external structure;
  2. Using an index, access the required field of an array of nested structures;
  3. Refer to the required field of the nested structure.

For example:

Let's look at an example of a structure representing information about a student and his courses at a university. Each student will have a name, age, and an array of courses they are taking. Each course will contain the title, instructor and number of credits.

Tarea

  1. In the Course structure, declare an array courseName, which will contain the name of the course;
  2. In the Student structure, declare an array studentName to store the student's name.
  3. In the Student structure, initialize the courses array, consisting of two nested Course structures.
  4. Use a loop to display course information.

Tarea

  1. In the Course structure, declare an array courseName, which will contain the name of the course;
  2. In the Student structure, declare an array studentName to store the student's name.
  3. In the Student structure, initialize the courses array, consisting of two nested Course structures.
  4. Use a loop to display course information.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 4. Capítulo 2
toggle bottom row

Struct with Arrays and Other Structs

In some structures there is a need to use an entire array of nested structures to describe more complex objects.

To get access to the required array element of a nested structure, you must:

  1. Refer to the external structure;
  2. Using an index, access the required field of an array of nested structures;
  3. Refer to the required field of the nested structure.

For example:

Let's look at an example of a structure representing information about a student and his courses at a university. Each student will have a name, age, and an array of courses they are taking. Each course will contain the title, instructor and number of credits.

Tarea

  1. In the Course structure, declare an array courseName, which will contain the name of the course;
  2. In the Student structure, declare an array studentName to store the student's name.
  3. In the Student structure, initialize the courses array, consisting of two nested Course structures.
  4. Use a loop to display course information.

Tarea

  1. In the Course structure, declare an array courseName, which will contain the name of the course;
  2. In the Student structure, declare an array studentName to store the student's name.
  3. In the Student structure, initialize the courses array, consisting of two nested Course structures.
  4. Use a loop to display course information.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 4. Capítulo 2
toggle bottom row

Struct with Arrays and Other Structs

In some structures there is a need to use an entire array of nested structures to describe more complex objects.

To get access to the required array element of a nested structure, you must:

  1. Refer to the external structure;
  2. Using an index, access the required field of an array of nested structures;
  3. Refer to the required field of the nested structure.

For example:

Let's look at an example of a structure representing information about a student and his courses at a university. Each student will have a name, age, and an array of courses they are taking. Each course will contain the title, instructor and number of credits.

Tarea

  1. In the Course structure, declare an array courseName, which will contain the name of the course;
  2. In the Student structure, declare an array studentName to store the student's name.
  3. In the Student structure, initialize the courses array, consisting of two nested Course structures.
  4. Use a loop to display course information.

Tarea

  1. In the Course structure, declare an array courseName, which will contain the name of the course;
  2. In the Student structure, declare an array studentName to store the student's name.
  3. In the Student structure, initialize the courses array, consisting of two nested Course structures.
  4. Use a loop to display course information.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

In some structures there is a need to use an entire array of nested structures to describe more complex objects.

To get access to the required array element of a nested structure, you must:

  1. Refer to the external structure;
  2. Using an index, access the required field of an array of nested structures;
  3. Refer to the required field of the nested structure.

For example:

Let's look at an example of a structure representing information about a student and his courses at a university. Each student will have a name, age, and an array of courses they are taking. Each course will contain the title, instructor and number of credits.

Tarea

  1. In the Course structure, declare an array courseName, which will contain the name of the course;
  2. In the Student structure, declare an array studentName to store the student's name.
  3. In the Student structure, initialize the courses array, consisting of two nested Course structures.
  4. Use a loop to display course information.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 4. Capítulo 2
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt