Sentinels, aren't those a variety of mutant-hunting robots from Marvel?

Greetings,

Well, I started programming C++ like 2 weeks ago, and now i'm learning how to read data from files, using sentinels and using the function atoi in this little practice.

How should this program work?
Well, I'll have a txt ready to be read in the default location with: * 21 3 5 10 20 * < 1 13 17 10 36 > ... ; between '*' I need to find wich is the greatest number and the lesser one and get the average of the numbers between < > so far i tried to test the < > part 'cause i guess it's easier, but each time i run the program, it just opens and after i type in the name of the txt, it closes...

Sorry if i did not explain myself right, english's not my native. Here's the code:

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <fstream>

using namespace std;

void parse()
{

	char name[20];
	double sum = 0, cont = 0, avg = 0;
	char temp[20];

	ifstream file;
	cout << "Introduzca el nombre del archivo: ";
	cin >> name;
	file.open(name);
	if (!file)
	{
		 system("cls");
		 cout << "Archivo no encontrado.\n";
		 system("pause");
		 return;
	}
	
	while(!file.eof())
	{
		file >> temp;
		if(strcmp(temp,"<") == 0)
		{
			while(strcmp(temp,">") != 0)
			{
				sum += atoi(temp);
				cont++;
			}
		}
		else if(strcmp(temp,"*") == 0)
		{
			return;
		}
	}
	avg = sum / cont;
	cout << avg;
	system("pause");
}

int main()
{
	parse();
	return 0;
}


Any ideas? Thanks!
Topic archived. No new replies allowed.