Dev - C++ - Error codigo dev c++

 
Vista:
sin imagen de perfil

Error codigo dev c++

Publicado por juan (1 intervención) el 10/05/2014 20:53:56
Tengo un error en el siguiente codigo:

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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
void CargarDatos(int &med, float &tem, int &cont){
	char cadena[128];
	float prom, num;
	string archivo;
	string linea;
	bool EncontroError=false;
	int n=0;
 
	cout << "     Cargar Datos " << endl;
	cout << "     ------------- " << endl;
	cout << "     Ingrese la ubicacion del archivo que desea abrir: ";
	cin >> archivo;
	cout << endl;
 
	//Verificar errores en el archivo
	ifstream in(archivo.c_str());
 
	while(getline(in, linea)){
		if(in==NULL){
			EncontroError=true;
		}
		if(EncontroError=true){
			cout << "       Error --> El archivo no existe " << endl << endl;
			break;
		}
	}
 
	while(getline(in, linea)){
		if(!in.is_open()){
			EncontroError=true;
		}
		if(EncontroError=true){
			cout << "       Error --> No se pudo abrir el archivo" << endl << endl;
			break;
		}
	}
 
	while(getline(in, linea)){
		if(EncontroError=true){
			cout << "       Error --> Datos incorrectos en el archivo" << endl;
			cout << "       Linea: " << linea << endl << endl;
			break;
		}
	}
 
	//Cargar Archivos
	ifstream in3(archivo.c_str());
 
	if(cont==1){
	    while(getline(in3, linea)){
	    	num=atof(linea.c_str());
			tem=tem+num;
			med++;
		}
 
	cont++;
	tem=(tem/med);
 
	cout << "     El numero de mediciones es: " << med << endl;
	cout << "     La temperatura promedio es: " << tem << endl << endl;
 
	in.close();
	}else{
		while(getline(in3, linea)){
			num=atof(linea.c_str());
			prom=prom+num;
			n++;
			med++;
		}
 
	prom=(prom/n);
	tem=((tem+prom)/2);
 
	cout << "     El numero de mediciones es: " << med << endl;
	cout << "     La temperatura promedio es: " << tem << endl << endl;
 
	in3.close();
	}
 
	system("PAUSE");
}

Se supone que cuando recibe un archivo con una linea que no sea un numero de punto flotante, un archivo que no se pueda abrir o un archivo que no exista deberia mandar el error y hacer un break, pero no hace el break y no entiendo porque?
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de JuanC

Error codigo dev c++

Publicado por JuanC (35 intervenciones) el 10/05/2014 22:55:05
en la línea
EncontroError=true

debe decir

EncontroError==true
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar