Original Post
i am trying to read a txt file using fstream fstream myfile("code.dat"); code.dat looks like this A BCDEF B CC C XXAA D W E . H and so on. every letter has its own code (letter A is BCDEF) I want to read these code into a structure i have created. struct structKodovi { char* cSlovo; char* cKod; }; so I do it like this: struct structKodovi Kodovi[28]; //28 lines in code.txt //reserve space for all letters and codes for (int =0;n<28;n++) { Kodovi[n].cKod = new char[5]; //code is maximum 5 chars Kodovi[n].cSlovo= new char; //leter is one char :) } /* now i read from code.dat -first i read first character on every line of txt (first is A) -then i seek +1 because i want to get the code -and then i read 5 characters of code (for A this is BCDEF) the programs reads A and BCDEF and puts it into Kodovi[0].cSlovo and Kodovi[0].cKod but there are 27 more codes to be read. I want the cursor to go to next line so i can read letter B and it's code into Kodovi[1] and so on... when it finishes reading first line tellg becomes -1 that means end of file. why? what am i doing wrong? I tried using getline insted, but the same happens. reads the first line of txt file and tellg becomes -1 and it doesnt read next lines of txt. Kodovi should be an array of structures where Kodovi[0] contains A and its code, Kodovi[1] B and its code and so on... */ for (int i=0;i<28;i++) { fKod.get(Kodovi.cSlovo, 2); fKod.seekg(ios::cur,+1); fKod.get(Kodovi.cKod, 6); }