#include <iostream>
#include <vector>
struct Point
{
char name[10];
int age;
};
void printArr(const std::vector<Point>& ar) //takes argument of type vector<Point> instead of arr of Point
{
for (int i = 0; i < ar.size(); i++)//use size() member function of std::vector
{
std::cout << "Name of " << (i + 1) << " person: " << ar[i].name<<"\n";
std::cout << "Age of " << (i + 1) << " person: " << ar[i].age<<"\n";
}
}
int main()
{
struct Point p;
int n;
do
{
std::cout << "Enter n: ";
std::cin >> n;
if (n <= 0)
std::cout << "Ama ti si bil mnogo tup da vuvedesh n<=0\n";
} while (n <= 0);
//create vector of POint of size n instead of array of Point
std::vector<Point> ar(n);
for (int i = 0; i < ar.size(); i++)//use size() member function
{
std::cout << "Enter name of " << (i + 1) << " person: ";
std::cin >> ar[i].name;
std::cout << "Enter the age of " << (i + 1) << " person: ";
std::cin >> ar[i].age;
std::cout << "\n";
}
std::cout << "Now we have to run the 'printArr' function!\n";
printArr(ar);
return 0;
}