Let's denote the number of students who bought hot dogs as \( H \) and the number of students who bought hamburgers as \( B \).
From the information given:
- \( H = 78 \) (the number of students who bought hot dogs).
- There were 45 more students who bought hamburgers than hot dogs, which we can express mathematically as: \[ B = H + 45 \]
Substituting the value of \( H \): \[ B = 78 + 45 \] \[ B = 123 \]
Now, we can find the total number of students who bought lunch by adding the number of students who bought hot dogs and hamburgers: \[ \text{Total students} = H + B = 78 + 123 \] \[ \text{Total students} = 201 \]
Therefore, the total number of students who bought lunch is \( \boxed{201} \).