School's out, and structs were the last thing I learned about in this C++ class I took at NC State. This semester was really about the C in C++. The object-oriented part comes in the spring. But by the time you get around to structs, you will have learned about file streaming, arrays, global constants, loops, all sorts of things. So, here's an example of reading mixed data -- strings of characters (like student names) and numbers (like student grades) -- from a text file:

// An example of using structs: reading data from a list of student
// names and grades, saved as a .csv file, into an array. In this
// example the file is saved as .csv, but the delimiter between
// name and grade is the tab character, '\t'. Also, the first row
// of the .csv file has variable names -- "name" and "grade" --
// so it must be skipped.

#include <iostream>
#include <fstream>
using namespace std;

const int NAMELEN=120; // longest name
const int LISTMAX=1000; // maximum number of students

struct Student {
  char name[NAMELEN];
  float grade;

void readList(char infilename[]);
// Arguments:
// file name, passed as an array of characters.
// Side effects:
// open file stream, function call of fillUp.

void fillUp(ifstream& inList, Student wholeClass[],
                        int LISTMAX, int& stCount);
// Preconditions: global constants LISTMAX and NAMELEN are the
// dimensions of the wholeClass[] and name[] arrays respectively.
// Postconditions:
// (1) grades[0] through grades[stCount-1] filled with positive
// real numbers read from input file stream open by readList.
// (2) names[0] through names[stCount-1] filled with
// array-based lists of characters up to NAMELEN long.

int main()
  char infilename[]="example_list.csv";
  return 0;

// open input, file stream call fillStudent to fill array named
// wholeClass[LISTMAX] with Student structs
void readList(char infilename[])
  ifstream inList(infilename); // input file stream
  if ( {
    cout << "Input file opening failed.\n";
  else {
    Student wholeClass[LISTMAX]; // initialize array of structs
    int stCount=0; // number of valid elements starts at zero
    fillUp(inList, wholeClass, LISTMAX, stCount);
    cout << "\nGrade Roll Report" << endl;
    cout << "There were " << stCount << " students." << endl;

// fill wholeClass[LISTMAX] using data from INFILENAME.
void fillUp(ifstream& inList, Student wholeClass[],
                        int LISTMAX, int& stCount)
  char dummy[NAMELEN]; // container for garbage.
  inList.getline(dummy,NAMELEN,'\n'); // toss the entire first row.
  for(int i=0; i<LISTMAX; i++) {
    while (stCount<LISTMAX &&
           inList.getline(wholeClass[i].name,NAMELEN,'\t')) {
      if(inList >> wholeClass[i].grade) {
        cout << "Name: " << wholeClass[i].name
             << " Grade: "<< wholeClass[i].grade << endl;

OK, so maybe the code above is a little over-commented for your taste, but they were very clear about how they wanted your programs in this course. There were points taken off for not commenting variables when you declared them, and the punishment for not commenting function prototypes was just a little short of a public flagellation.

I like this way of doing business. I learned my programming in the haphazard way that all social scientists do -- you write code in your statistical programming environment of choice, see to it that it does the job, and that's that. This, of course, bit me back numerous times over the years, so I did eventually come to appreciate the true cost of sloppiness. In computer science you don't get a chance at that sort of revelation, because bad practice is nipped in the bud. The textbook quoted Oscar Wilde before the first chapter was over: "In matters of grave importance,  style, not sincerity, is the vital thing."