#include #include // for ifstream #include // for exit #include using namespace std; #include "strutils.h" // for atoi #include "clockt.h" #include "prompt.h" // reads file containing data for a cd in format below (one line/track) // min:sec title // and sums all track times int main() { ifstream input; string filename = PromptString("enter name of data file: "); input.open(filename.c_str()); if (input.fail()) { cerr << "could not open file " << filename << endl; exit(0); } string minutes, // # of minutes of track seconds, // # of seconds of track title; // title of track ClockTime total(0,0,0); // total of all times while (getline(input,minutes,':') && getline(input,seconds,' ') && getline(input,title)) // reading line ok { ClockTime track(atoi(seconds.c_str()),atoi(minutes.c_str()),0); cout << track << " " << title << endl; total += track; } cout << "------------------------------" << endl; cout << "total = " << total << endl; return 0; }