I should write a code, which will print the names and faculties of those students, whose years and groups are equal to the numbers which the user inputs, but after compiling, it doesn't leave space for writing the name, why?
#include <iostream>
using namespace std;
struct student
{
char name[40];
char faculty[20];
int year;
int group;
};
void input(student &x)
{
cout << "Name: "; cin.getline(x.name, 40);
cout << "Faculty: "; cin.getline(x.faculty, 20);
cout << "Year: "; cin >> x.year;
cout << "Group: "; cin >> x.group;
}
int main()
{
const int n = 4;
student arr[n];
int a, b;
cout << "Input number 1: ";
cin >> a;
cout << "Input number 2: ";
cin >> b;
cout << "_______________________________" << endl;
for (int i = 0; i < n; i++)
input(arr[i]);
for (int i = 0; i < n; i++)
if (a == arr[i].year && b == arr[i].group)
cout << arr[i].name << " - " << arr[i].faculty << endl;
return 0;
}