Homework Error

ok I am making a program that asks this

Create a structure for a classroom. Make sure it includes the following:

Room Number,
Lecture Name,
List of Students,
Number of chairs,
Window (Yes/No),
Projector (Yes/No),
Available(Yes/No).

Instructions:

Create functions that allow you to add data to the attributes of the classroom.
Create functions that allow you to print out the classroom information.
Compare two classrooms based on the size (number of chairs) and report which classroom is larger. Also compare two classrooms base on utilization.


My issue is, this is all I got so far and the only thing I ma confused about and I am sure it is something simple is when I get to where I enter the students name, if I put a first and last name in then it skips the second student and clsoes program. This is confusing me heavily so I am asking if you can tell me why it is doing that

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  #include "stdafx.h"
#include<iostream>
#include<string>
#include<vector>
using namespace std;

struct Classroom{

	int RoomNum;
	string lname;
	string StudList;
	int Chairs;

	
	void classinfo1(int, string){
		int Studn;
		vector<string> Stud;
		Classroom clss;
		cout << "Please enter the first classrooms info\n";
		cout << "Room number\n";
		cin >> clss.RoomNum;
		cout << "Lecture name\n";
		cin >> clss.lname;
		cout << "number of chairs in the class\n";
		cin >> clss.Chairs;
		cout << "How many students is in your class?\n";
		cin >> Studn;

		for(int i = 0; i < Studn; ++i){
			cout << "enter student " << i + 1 << endl;
			cin >> clss.StudList;
			Stud.push_back(clss.StudList);

		}


	}

		
};



int main()
{
	int a = 0; string b;
	Classroom now;

	now.classinfo1(a, b);
	

	system("pause");
	return 0;
}
Use getline() to make it record spaces,
ex (from SO):
1
2
   std::cout << "Enter your name: ";
   std::getline(std::cin, name);

Using a debugger or having print statements to see if your code is "on the right track" can help a lot to determine what's going on
Last edited on
Brilliant, thats what it is. thank you bro I appreciate it for some reason I was wanting to try to use cin.get()
Ahh it still makes it jump without being able to enter the name if i use getline
Topic archived. No new replies allowed.