Multiple inputs using for loops

Why it’s taking only two inputs from user

#include

#include

using namespace std;

int main()

{

string name, school;

int n = 4, roll, clas;

for (int i = 0; i < n; i++)

{

    cin >> name;
    cin >> school;
    cin >> roll ;

}

}

When input is scanned, once integers are done, then the left out part is taken as string in your case. Hence \n is geeting read in school. You can avoid this by flushing or reading extra string.