J
jerryalan
I'm doing an assignment for class where I need to create a gradebook.
I have it working well but I'm having a hard time getting student names
inputted with spaces. I am using a pointer to create a new object (to
dynamically size the student array to the size specified by the
teacher).
Here is my code:
string * ps = new string[students];
for(int i = 0; i < students; i++)
sa = new int[assignments];
cout << "\nNow I need you to enter the names of your students\n";
for (int i = 0; i < students; i++) {
cout << "Please enter the name of student " << i + 1 << ": ";
cin >> ps;
}
I've tried cin.getline(ps); but that gave me a compiler error (error
C2664). I'm using the Sams book: C++ Primer Plus and I've searched for
a while but can't fine the solution. Can anyone help me with this so I
can enter first and last names of students?
Thanks,
I have it working well but I'm having a hard time getting student names
inputted with spaces. I am using a pointer to create a new object (to
dynamically size the student array to the size specified by the
teacher).
Here is my code:
string * ps = new string[students];
for(int i = 0; i < students; i++)
sa = new int[assignments];
cout << "\nNow I need you to enter the names of your students\n";
for (int i = 0; i < students; i++) {
cout << "Please enter the name of student " << i + 1 << ": ";
cin >> ps;
}
I've tried cin.getline(ps); but that gave me a compiler error (error
C2664). I'm using the Sams book: C++ Primer Plus and I've searched for
a while but can't fine the solution. Can anyone help me with this so I
can enter first and last names of students?
Thanks,