problem with reading txt file into vectors of vectors

Hi, i have the problem mentioned in the header: my file looks as this:

Iso: pfmkk600ta70lp703
T050S 1
D05030 2

Iso: pfmzv600ta70000
T050S 1
D05030 1
R0500200S 9
R0501000S 1

and so on. All terms shall be stored into different containers:Iso.. into a vector,
T050S and so on into a vector< vector<string> > and the numbers like 9 into
vector< vector<int> >.

my code is this:

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
#include <iostream>
#include <fstream>
#include <string> 
#include <vector>
#include <sstream>
#include <stdio.h>
using namespace std;

int main() {
    
    
  FILE *file;
  
  vector<string> isometrie;
  vector < vector<int> > isorohranzahl;
  vector < vector<string> > isorohrtypen;
  char tempchar[30];
  vector<string> tempstring;   
  int x=0;
  int w;                                                                                                                             
   file = fopen("isometrien.txt", "r");
  if(file==NULL) {                                                                                                        
    printf("Error: can't open file.\n");
    return 1;
  }
  else {
    printf("File opened successfully.\n");
    w = 0 ;
    while(!feof(file)) { 
       isom:;
       fscanf(file, "%s", tempchar);
       tempstring.insert(tempstring.end(),tempchar);
       size_t findiso=tempstring[x].find_last_of("Iso");
       if (findiso!=string::npos)
       {isometrie.insert(isometrie.end(),tempchar);
      w++; x++;
      isorohrtypen.resize(w);
      isorohranzahl.resize(w);
      goto isom;
      }
       if(findiso=string::npos)
       {int n=0;x++;
       isorohrtypen[w].insert(isorohrtypen[w].end(),tempchar);
       isorohranzahl[w].resize(x);
       fscanf(file,"%d",&isorohranzahl[w][x]);
       
       }}
       int g;
     int t;
    for (t=0; t<2; t++)
    {cout<<isometrie[t]<<endl;
        for (g=0; g<2 ;g++)
        {
            cout<<isorohrtypen[t][g]<<" "<<isorohranzahl[t][g]<<endl;
            
            }

            }}
       fclose(file);
       cin.get();
       
            }


i do not get any error messages from the compiler (dev-c++),
but a windows-window pops up and says "there is a problem" and the program doesnt work. could anyone help me, i guess there is a problem with the code?

best, sajakob
Last edited on
no reply... . I mean is my code not even wrong?
Topic archived. No new replies allowed.