[Note: This was from a homework assignment, but I believe the code is all correct aside from this problem. A helpful hint or someone pointing out that I was mistaken in that assumption would really be appreciated).
This is a 24-hour to 12-hour conversion assignment emphasizing the use of file input (strings, EOF, etc.). All the separate parts/functions are correct; the only way I could see this not working is that the program is refusing to open the input file I had made for it. I do not know why that is happening and would appreciate any pointers. Here is my code below:
-
#include <iostream>
#include <fstream>
using namespace std;
int readtime(ifstream& infile, int& hours, int& mins);
char convert(int& hours);
void showtime (ofstream& outfile, int hours, int mins, char AorP, int orighours);
void main(void)
{
ofstream outfile;
ifstream infile;
int hours, mins;
char AorP;
char filename[100];
char ans;
int eof;
int hours2;
ans='y';