задача на структуры
Как подсчитать количество студентов, которые прописаны на заданной с клавиатуры улице.
#include<iostream>
#include <string>
#include<Windows.h>
using namespace std;
struct Students
{
char name[20];
char surname[20];
char adress[40];
char gender[15];
int numberofgroup;
};
int main()
{
bool ReadFile(Students * &arr_Students, int& size);
void print(Students * arr_Students, int size);
setlocale(0, "");
int size;
Students* arr_Students;
if (ReadFile(arr_Students, size))
print(arr_Students, size);
else
cout << "Error opening file!" << endl;
cin.get();
return 0;
}
bool ReadFile(Students*& arr_Students, int& size)
{
ifstream fin("Text.txt");
if (!fin)
return false;
(fin >> size).get();
arr_Students = new students[size];
for (int i = 0; i < size; i++)
{
fin.getline(arr_Students[i].name, 20);
fin.getline(arr_Students[i].surname, 20);
fin.getline(arr_Students[i].adress, 40);
fin.getline(arr_Students[i].gender, 15);
fin >> arr_Students[i].numberofgroup;
fin.get();
return true;
}
fin.close();
}
void print(Students* arr_Students, int size)
{
for (int i = 0; i < size; i++)
{
}
}