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> >.
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
usingnamespace std;
#include <stdio.h>
int main() {
FILE *file;
vector<string> isometrie;
vector < vector<int> > isorohranzahl;
vector < vector<string> > isorohrtypen;
int x=0;
int w;
file = fopen("isometrien.txt", "r");
char tempchar[30];
vector<string> tempstring;
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;
isorohrtypen[w].insert(isorohrtypen[w].end(),tempchar);
isorohranzahl[w].resize(x+1);
fscanf(file,"%d",&isorohranzahl[w][x]);
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?