How to store an input in a string for as many inputs as I want

I am writing a code for a student list. The user can choose to input the number of students, and then the program will ask the user to give a name for each student, which can be up to 45. I cannot use an array or vector for this program. I don't know how to do this. (Also new to c++, and I don't have the required textbook)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 if (User_Choice == 1) {
	ofstream outfile("Student.txt");
	cout << "\n";
	cout << "Enter a number of students, 5 - 45, inclusive > ";
	cin >> Num_Students;

	if (Num_Students < 5 || Num_Students > 45) {
	cout << "Invalid number - Please try again";
	goto reset;
	}

	while (Num_Students) {
	cout << "\nEnter the full name of student " << Students_List << " > "; // int count
	getline(cin, current, '\n');
	outfile << current;
	Students_List++;
	Num_Students--;
	}
	outfile.close();
}
Your sample code stores names into a file. Is that not your intention?

Here is one string, a comma-separated list with three "items" in it:
"Mary Sue, John Doe, Jane"
@keskiverto

I guess what I mean is that I want a .txt file with the names on different lines, but when I run my program as-is, the output is all of the names together with no spaces.
add newlines,
 
outfile << current << '\n';
@Ganado
That worked! Thank you
Registered users can post here. Sign in or register to post.