There is a file with the following text content:

| .. | ............ | ............ |

| .. | U ........... | ............ |

| .. | ... R ........ | ............ |

Between the lines is a single hyphen, not double. I just do not know how to insert it correctly, so that it is like in a notebook.

enter image description here .

It is necessary to read this part in every line.

"U ........... | ............ |"

Here is my code:

#include <iostream> #include <fstream> #include <string.h> #include <conio.h> using namespace std; char PowerReset[4]; char Up1[1],Down1[1],Left1[1],Right1[1],A1[1],B1[1],C1[1],S1[1],X1[1],Y1[1],Z1[1],M1[2]; char Up2[1],Down2[1],Left2[1],Right2[1],A2[1],B2[1],C2[1],S2[1],X2[1],Y2[1],Z2[1],M2[2]; string g = ""; int main() { ifstream read1("D:\\Input_Log.txt"); if (!read1.is_open()) { cout << "Failed to open a file!" << endl; _getch(); return 0; } while(!read1.eof()) { read1.getline(PowerReset, 4 /*,'|'*/); read1.getline(Up1, 1); read1.getline(Down1, 1); read1.getline(Left1, 1); read1.getline(Right1, 1); read1.getline(A1, 1); read1.getline(B1, 1); read1.getline(C1, 1); read1.getline(S1, 1); read1.getline(X1, 1); read1.getline(Y1, 1); read1.getline(Z1, 1); read1.getline(M1, 2); read1.getline(Up2, 1); read1.getline(Down2, 1); read1.getline(Left2, 1); read1.getline(Right2, 1); read1.getline(A2, 1); read1.getline(B2, 1); read1.getline(C2, 1); read1.getline(S2, 1); read1.getline(X2, 1); read1.getline(Y2, 1); read1.getline(Z2, 1); read1.getline(M2, 2); if (*S1 == '.') g += '0'; else g += '1'; if (*C1 == '.') g += '0'; else g += '1'; if (*B1 == '.') g += '0'; else g += '1'; if (*A1 == '.') g += '0'; else g += '1'; if (*Right1 == '.') g += '0'; else g += '1'; if (*Left1 == '.') g += '0'; else g += '1'; if (*Down1 == '.') g += '0'; else g += '1'; if (*Up1 == '.') g += '0'; else g += '1'; if (*S2 == '.') g += '0'; else g += '1'; if (*C2 == '.') g += '0'; else g += '1'; if (*B2 == '.') g += '0'; else g += '1'; if (*A2 == '.') g += '0'; else g += '1'; if (*Right2 == '.') g += '0'; else g += '1'; if (*Left2 == '.') g += '0'; else g += '1'; if (*Down2 == '.') g += '0'; else g += '1'; if (*Up2 == '.') g += '0'; else g += '1'; if (*M2 == '.') g += '0'; else g += '1'; if (*Z2 == '.') g += '0'; else g += '1'; if (*Y2 == '.') g += '0'; else g += '1'; if (*X2 == '.') g += '0'; else g += '1'; if (*M1 == '.') g += '0'; else g += '1'; if (*Z1 == '.') g += '0'; else g += '1'; if (*Y1 == '.') g += '0'; else g += '1'; if (*X1 == '.') g += '0'; else g += '1'; //cout << Up1 << Down1 << Left1 << Right1 << A1 << B1 << C1 << S1 << X1 << Y1 << Z1 << M1; } read1.close(); //cout << g << endl; //отсутствует операнд "<<" (перед g), соответствующий этим операндам return 0; } 

The code is terrible, no doubt, but I already bite my elbows, because I can not understand why the while loop does not work. Why?

  • What does "not working" mean? - VTT
  • @VTT Apparently, some kind of reading error. I can not display anything on the console and in general make sure that I am on the right track. Nowhere in the loop, not after it does not work cout. - Dmitry Moskovchenko
  • Well, and you can specifically write what is happening? Here we went into the loop, execute the first read1.getline(PowerReset, 4 /*,'|'*/); - is it running or not? Is the string read or not? and where it stops working as it should - VTT
  • @YTT Here before this line or during its execution occurs stupor. The console doesn’t react to anything and output nothing if I uncomment cout at the end of the cycle. In general, I do not know the reason! - Dmitry Moskovchenko
  • And what exactly is the stock stupor? cout is not needed at all - VTT

0