Changing the input of my program

I wrote this program which converts a time from 24 hour notation to 12 hour notation but I need to change it so it reads in the times one line at a time from a txt file and then converts those time. I only need to make a few changes but my function prototypes should look similar to this:

int gettime(ifstream& infile, int& hours, &int mins); // the int returned is a yes/no value indicating if EOF has occurred
char convert(int& hours);
void showresults(ofstream& outfile, int hours, int mins, char ampm, int orighours);



My current program is below, if anyone has any pointers for me I would really appreciate it.

#include <iostream>
using namespace std;

void input(int&, char&, int&, char&);
void conversion(int&, int&, char&);
void output(int&, int&,char&);

int main()
{

int hours, minutes;
char answer, period, colon;

do
{
input(hours, colon, minutes, period);
cout << endl;
conversion(hours, minutes, period);
output(hours, minutes, period);
cout << endl;

cout << endl << "Would you like to convert another time? (Y/N)";
cin >> answer;
cout << endl;
}
while(answer == 'y' || answer == 'Y');

return 0;
}

void input(int& hours, char& colon, int& minutes, char& period)
{
cout << "Please enter the time in 24 hour notation: ";
cin>>hours>>colon>>minutes;

}

void conversion(int& hours, int& minutes, char& period)
{
if(hours > 12)
{
hours = hours - 12;
period = 'p';
}
else if(hours == 12) period = 'p';
else period = 'a';
}

void output(int& hours, int& minutes, char& period)
{
cout << "Your time in 12-hour notation: ";

if(period == 'p')
{
if(minutes < 10) cout << hours << ":0" << minutes << " PM";
else cout << hours << ":" << minutes << " PM";
}
else
{
if(minutes < 10) cout << hours << ":0" << minutes << " AM";
else cout << hours << ":" << minutes << " AM";
}

}



Thank you
Topic archived. No new replies allowed.