c++ - I would like to know why my reading of the file is stopping early -


I'm a beginning C ++ user and I have tried to cooperate with my classmates and in this way, but we The answer to this question is that our instructor has given us a linker who runs the main function for us and provides a simple text file for us to read, and for the time being in the second const char * in the title is unimportant , Now for me all Read the data from the file concrete char * saiffile and display it on the screen when I run my program, I have found that it starts reading and I think you will not be able to help because you do not have access to the linker. But any help would be greatly appreciated.

Here's my all code:

  # include & lt; Iostream & gt; # Include & lt; Fstream & gt; # Include & lt; iomanip & gt; using namespace std; Const int DESC_SIZE = 37; Structure item {int itemId; Description of the character [DESC_SIZE]; Double cost, value; }; Int ProcessIfile (Const four * Safffile, Const char * Raffey) {Fistruff Outfile, Infile; Item inventory; InFile.open (Saiffile, iOS :: In); While (Infile) {inFile & gt; & Gt; Inventory. Item ID & gt; & Gt; Inventory.cast & gt; & Gt; Inventory.price; InFile.getline (Inventory Desscription, DESC_SECE); Cout & lt; & Lt; "" & Lt; & Lt; Inventory. ITMID & lt; & Lt; "" & Lt; & Lt; Setup (5) & lt; & Lt; Inventory.cast & lt; & Lt; "" & Lt; & Lt; Setup (5) & lt; & Lt; Inventory.Print & lt; & Lt; "" & Lt; & Lt; Inventory Description & lt; & Lt; Endl; } Return 0; }    

Make sure that the type of data you have received is inFile < / Code> matches the type that reads Infile . If not, you will get a stream error and it will stop reading your program.

After every read, try inFile.clear () and see if your program is hanging or initially prevents. Alternatively, after each reading Try

  if (inFile.fail ()) {cout & lt; & Lt; "Read error in file \ n"; }   

This can not be the answer, but I would like to start debugging here.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -