#include <iostream>
using namespace std;
int main()
{
int N;
int T;
cin>>N;
struct key {
std::string namek;
int szam;
int szat;
std::string kol;
};
key kert[N];
for (int i=0; i<N; i++) {
int k=i;
cin.ignore(100, ' ');
getline(cin, kert[k].namek);
cin>>kert[k].szam;
cin.ignore(100,' ');
cin>>kert[k].szat;
cin.ignore(100, ' ');
getline(cin, kert[i].kol);
}
for (int i=0; i<N; i++) {
int k=i;
cout<<kert[i].namek;
}
I want to read into the the 'kert' struct but my program only reads into kert[0] and then returns. I don't know where I messed up because I used getline for strings and cin for ints. I know cin leaves the '\n' in the buffer and tried reading dummy chars after cin , I also tried cin.ignore (as in the code) but nothing helps. Where did I mess up?