Answered step by step
Verified Expert Solution
Question
1 Approved Answer
* The requirements are to use char arrays for string data but this program uses std::string. * The requirements say that you cannot use continue
The requirements are to use char arrays for string data but this program uses std::string.
The requirements say that you cannot use "continue" but this is in the main loop in main.cpp
The insertData function doesn't parse the input line
The insertData function doesn't place items into the array
The output format of printReport is incorrect
main.cpp:
#include
#include
#include "functions.h
#include "assignment.h
using namespace std;
int mainint argc, char argv
if argc
cerr "Usage: argv endl;
return ;
ifstream fileargv;
if file.isopen
cerr "Error opening file." endl;
return ;
Assignment assignmentsMAXASSIGNMENTS;
int numAssignments ;
string line;
while getlinefile line
if lineempty line#
continue; Skip empty lines and comments
insertDataassignments numAssignments, line;
file.close;
printReportassignments numAssignments;
return ;
functions.cpp:
#include "functions.h
#include
void insertDataAssignment assignments int& numAssignments, const std::string& line
Placeholder implementation
Extract data from the line and insert it into the assignments array
For now, let's just print the line to simulate inserting data
std::cout "Inserting data: line std::endl;
Increment numAssignments for the next assignment
numAssignments;
void printReportconst Assignment assignments int numAssignments
Placeholder implementation
Print report based on the assignments array
std::cout "Printing report..." std::endl;
for int i ; i numAssignments; i
Print each assignment
std::cout "Assignment i : assignmentsiday
assignmentsitask assignmentsiwho std::endl;
assignment.h:
#ifndef ASSIGNMENTH
#define ASSIGNMENTH
#include Add this line
const int MAXASSIGNMENTS ;
struct Assignment
int day;
std::string task; Use std::string" instead of just "string"
std::string who; Use std::string" instead of just "string"
;
#endif ASSIGNMENTH
functions.h:
#ifndef FUNCTIONSH
#define FUNCTIONSH
#include "assignment.h
#include
void insertDataAssignment assignments int& numAssignments, const std::string& line;
void printReportconst Assignment assignments int numAssignments;
#endif FUNCTIONSH
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started