Structures and Arrays Question

I have completed most of the problem I've been working on so far. This is the full question (1-4). I am having trouble with parts 2-3.

This is the question:

1. Write a function print_student_info that takes in a Student struct and print all its information.

2. Write another function search_students_by_lastname that take in an array of Student struct and string lastname as arguments and print the information of all students that match the given lastname. Use the print_student_info function in (1). If no structure matches, print a message “0 Matches found for the given lastname“.

3. Write another function search_students_by_yob that search for a student born in a particular year. It should take in an array of Student struct and an int yob as arguments and then search for all students with a birth year that matches it. Use print_student_info function to print the information of the matched structures. If no structure matches, print a message “0 Matches found for the given year of birth“

4. Write a main function to test the developed aforementioned functions. You should create an array of struct Student and fill it in with six students of arbitrary appropriate values. Then demonstrate the usage of search_students_by_lastname and search_students_by_yob functions.

I need help completing parts of 2, 3 and 4.

This is what I have so far:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <string>
using namespace std;

struct Student                  //creates structure student
{
    char firstname;             //listing variables inside structure
    char lastname;
    struct dob
    {
        int year;
        int month;
        int day;
    };
    dob a;
    double number;
    char major;
};

void print_student_info(Student s) //function that calls to structure Student
      {
          cout << "First Name: " << s.firstname << endl;      //Prints student info
          cout << "Last Name: " << s.lastname << endl;
          cout << "Date of Birth(MMDDYYYY): " << s.a.month << s.a.day << s.a.year << endl;
          cout << "Phone Number: " << s.number << endl;
          cout << "Major Field of Study: " << s.major << endl;
      }

void search_students_by_lastname(Student s)
{
    struct Student lname[6];
    int i;
    for(i=0; i < 6; i++)
    {
        
    }
}

void search_students_by_yob(Student s)
{
    
}

int main()
{
    
}
Last edited on
Quit creating new threads for the same problem. This is the 3rd one I've seen in this forum alone.
Topic archived. No new replies allowed.