I have a struct called Person:
Person
{
int id;
int age;
int salary;
};
So I want to enter as many Person as I want with the standard input in one line of the following form:
[id, age, salary] [id, age, salary] ...
So I did write this code but it doesn't give me what I'm looking for:
std::vector<Person> person;
int y = scanf("%i", &num);
for (int i = 0; i < num; i++)
{
Person p;
int r = scanf("[%i,%i,%i]", &p.id, &p.age, &p.salary);
person.push_back(p);
}
How can I correct my code to satisfy my need?