Initializing an array of structs is similar to a multi-dimensional array:
Code:
lessons info[10] = {
{ "Physical education", "Harry", "Pleter", 32 },
{ "History", "Emily", "Shelton", 12 },
etc, etc
};
Reading it from a file though, that a whole different beast. You need to think about the format, for starters. For example, if you use spaces for the different fields, then the lesson name can only be a single word. We usually go with a symbol that won't be used for anything else, or we "escape" symbols that might conflict with formatting.
For simple things though, you could just use fscanf() for its built-in pattern matching, although that would make it quite complicated... Take a look at this example that parses 4 comma-separated strings:
Code:
if (fscanf(file, "%[^,\n],%[^,\n],%[^,\n],%[^,\n]", str1, str2, str3, str4) != 4 || fgetc(file) != '\n') {
fprintf(stderr, "Error: Invalid format at line #%d\n", line);
exit(1);
}