0
#include <iostream>
using namespace std;

int main()
{
    string studentName;
    char grade;
    string teacherComment;

    cout << "Enter student name: ";
    getline(cin, studentName);
    cout << "Enter grade: ";
    cin >> grade;
    cout << studentName << " has received a grade of " <<grade<< endl;
    cout << "Enter comments: ";
    getline(cin, teacherComment);
}

I know the getline() function is used to get a string of text input from the user, but how come it won't work the second time? My program runs fine, it's just that it doesn't recognize the last line of code.

image

Remy Lebeau
  • 505,946
  • 29
  • 409
  • 696
chino
  • 11

0 Answers0