data struct using strings

Hi, my problem is that when I execute it, it would not put people name and grade how I want it to be. for example

name grade
J 75
K 85

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


#include <iostream>
#include <string>

using namespace std;

    struct student
{

    string name;
    int grade;

};

 int main()
 {
     student people1;
     student people2;


     cout << "Please enter student name: ";
     cin >> people1.name;
     cout <<" Pleae enter student grade: ";
     cin >> people1.grade;

     cout << "Please enter student name: ";
     cin >> people2.name;
     cout <<" Pleae enter student grade: ";
     cin >> people2.grade;

     cout << "Name" << "          " << "Grade" << endl;

   cout << " people1.name " << "        " << " people1.grade " << endl;

   cout << " people2.name " << "        " << " people2.grade " << endl;

     cin.get();

 }
You need to get rid of the quotes where you print the student's name and grade.

1
2
3
4
5
6
7
8
//this prints "people1.name   people1.grade"
cout << "people1.name" << "   " << "people1.grade" << endl;

people1.name = "Kenny";
people1.grade = 0;

//this prints "Kenny   0"
cout << people1.name << "   " << people1.grade << endl;
Topic archived. No new replies allowed.