Input File

I need help displaying the number of tasks for an event from the text file that I have created and input into my program. Please help! I'm posting the code in here.

#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

void header();
void footer();
int convert(int);

int pnum = 0;
const int width = 22;
const int SENTINEL = 0;

int main()
{
ifstream infile;

infile.open("CritPath.txt"); // associate “testdata.txt with infile

// Important to check if file exists
if (!infile)
{
cerr << "File could not be opened\n"; //display error message
exit(1); // end program

}

int event, numOfTasks, daysInEvent;

header();

infile >> event >> numOfTasks >> daysInEvent;

while (event != SENTINEL)

{
if (event > pnum)
{
cout << setw(20) << event << setw(19) << numOfTasks << setw(20) << daysInEvent << endl;
pnum = event;
}
infile >> event >> numOfTasks >> daysInEvent;


}

footer();

cout << setw(46) << "Number of Events: " << endl;
cout << setw(46) << "Total Number of Days: " << endl;
cout << setw(46) << "Longest Event to Complete: " << endl;

return 0;
}

int convert(int n)
{
int weeks;
int days;

weeks = n / 5;
days = n % 5;

return(weeks, days);
}

void header()
{
cout << setw(50) << "Critical Path Analysis\n";
cout << "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \n";
cout << setw(width) << "Event" << setw(width + 1) << "Number of Tasks" << setw(width) << "Days in Event\n";
cout << "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \n";
}

void footer()
{
cout << "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \n";
cout << setw(48) << "Project Summary\n";
cout << "= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \n";
}
Topic archived. No new replies allowed.