time from input file?

I need to read a time from an input file and translate it into manipulate-able integers for a larger program, but for the sake of learning how to work things out myself, I want to know how I would separate an entry into hours and minutes given a "txt" file that reads like so:

8:45, 9:45, etc...

here's my coding so far, attempting it by simply discarding the semicolon, to no avail... (novice work, i know:)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()
{
	char time[256];
	char c;
	char HH;
	char MM;

	ifstream inFile;

	inFile.open("time.text");

	inFile >> time;

	HH = inFile.get();
	
	inFile.ignore(':');

	MM = inFile.get();
	
	cout << HH << "hours, " << MM << " minutes." << endl;

	system ("PAUSE");
	return 0;
}


any ideas?
You will need to loop through the file and read until the end.
You can use substring to remove the colon. You can use a stringstream to conver the string 'HH' to int and same for minutes.
Topic archived. No new replies allowed.