Why is this crashing?

Hey, i've been stuck for a day or two trying to search the web on how to fix this problem and i haven't got positive results so i decided to register here.

This is for an assigment, we are supossed to make a program that reads a txt file containing our career program and convert it into some data structure so the program can also recover certain stuff.

Problem wasn't that hard and i can retrieve the information, but the problem is that one of my functions crashes.

i'm running this to try and identify the problem. (our primary language is spanish so some of the name's i used are in spanish, hopefully that doesn't pose a problem)


1
2
3
4
5
int main (){
   lista malla;
   malla = armar_lista();
   mostrarAsignatura(520141,malla);
   return 0;


}

here's a screenshot, i'm running this on windows xp with codeblocks.

http://i43.tinypic.com/efjxqx.jpg



"si se ve" is spanish for "it shows" and "no se ve" -> "it doesn't show"

i'm going to put some more of the code so you can understand more what im trying to do and hopefully can tell me what i'm doing wrong.


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
82
83
84
85
86
87
88
lista armar_lista (){
  lista z;
  string line;
  node temp;
  z = lista();
  ifstream myfile("malla.dat");
  if (myfile.is_open())
  {
    while (! myfile.eof() )
    {
      getline (myfile,line);
      temp = get_asignatura(line);
      z.add(temp);
    }
    myfile.close();
  }

  else cout << "No se puede abrir el archivo";
  return z;

}

node get_asignatura(string str){
  node *z = new node;
  z->codigo = convert(str.substr (0,str.find(",")));
  str = trim(str.substr (str.find(",")+1));
  z->nombre = str.substr (0,str.find(","));
  str = trim(str.substr (str.find(",")+1));
  z->creditos = convert(str.substr (0,str.find(",")));
  str = trim(str.substr (str.find(",")+1));
  z->semestre = convert(str.substr (0,str.find(",")));
  str = trim(str.substr (str.find(",")+1));
  z->licenciatura = convert(str.substr (0,str.find(",")));
  str = trim(str.substr (str.find(",")+1));
    if (str.find(",")==1){
  z->especializacion = convert((str.substr (0,str.find(","))));
  z->requisitos  = trim(str.substr (str.find(",")+1));}
  else{
      z->especializacion = convert(str.substr (0));
      z->requisitos = "";
  }
  return *z;
  };

void lista::add(node x)

{

     node *t;



   if( final == NULL )

   {

        final = new node;

      final->codigo = x.codigo;
      final->nombre= x.nombre;
      final->creditos= x.creditos;
      final->semestre= x.semestre;
      final->licenciatura= x.licenciatura;
      final->especializacion=x.especializacion;
      final->requisitos=x.requisitos;
      final->nxt = NULL;
      inicio = final;

   }

   else
   {


      t = new node;

      t->codigo = x.codigo;
      t->nombre= x.nombre;
      t->creditos= x.creditos;
      t->semestre= x.semestre;
      t->licenciatura= x.licenciatura;
      t->especializacion=x.especializacion;
      t->requisitos=x.requisitos;
      t->nxt = NULL;
      final->nxt = t;
      final = final->nxt;

   }


Last edited on
If you are having a problem with this function mostrarAsignatura why did you not post it like you have the functions above rather than as a picture??

But looking at the picture you posted:

while(a=true) //wrong??

You probably meant while(a==true).

You can just write while (a)
LOL, epic fail for me there.

Topic archived. No new replies allowed.