Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How would I convert two arrays in this header file into a struct? #ifndef STUDEN

ID: 3653784 • Letter: H

Question

How would I convert two arrays in this header file into a struct?

#ifndef STUDENTS_H

#define STUDENTS_H


#include <string>


struct Student

{

std::string studentNames;

int studentCredits;

};


Student numStudents;


// Initialize all student data, allowing for at least the indicated

// number of students

void initializeStudents(int maxStudents);


// Clean up student data

void cleanUpStudents();



// Add a student, starting with 0 credits. Return position where

// inserted.

int addStudent (std::string studentsName);


// Add a number of credits taken by a student

int addCredits (std::string studentName, int credits);



#endif

Explanation / Answer

//you'll have to use pointers for dynamic arrays, and maybe add a size member to that structure...or just make static array with lots of elements. struct Student { std::string *studentNames; int *studentCredits; int size; }; or struct Student { std::string studentNames[1000]; int studentCredits[1000]; int count; };

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote