Returning a struct

This example shows you how to return a structure from a function.

Think of the following when reading this:

  • The struct is created locally and return.
  • By creating the struct in a dedicated function, we can easily implement error checking that will always be present.
  • This also works nicely if you need to read multiple structs into a struct array.
  • This also works for when reading from files.