I am new in coding and in this community I want to save multiple student info in multiple file in ".txt" file like "student1.txt", "student2.txt", "student3.txt" etc. See my code then I hope you will understand my problem.
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main() {
    for(int i = 1; i < 30; i++) {
        string name, roll, gpa;
        cout << "Enter student info";
        cout << "name :";
        cin >> name;
        cout << "\nEnter Roll :";
        cin >> roll;
        cout << "\nEnter gpa :";
        cin >> gpa;
        ofstream file;
        /* Problem part :I know this part of code will never work */
        file.open("Student  <<i<<".txt");
        /* what should I do */
        file << name << endl << roll << endl << gpa;
        file.close();
    }
}
 
     
    