I want to take students name and id and then print them. How can I do it? I used a string array "name[20]" for storing name and an int array "id[20]" for storing id. I used getline() for name array and cin for id array inside same for loop. But problem is it is not taking id values. My code is
#include <iostream>
#include <cstring>
using namespace std;
int main(){
    int n, i;
    string name[20];
    int id[20];
    for ( i=0; i<=20; i++){
        getline(cin, name[i]);
        cin>>id[i];
    }
    for ( i=0; i<=20; i++)
        cout<<name[i]<<"    "<<id[i]<<"\n";
}
