I'm trying to write the program to read strings into an array. I used the code to see if the file was opening and it did not indicate that it failed(I have since removed that code, just stating that the file opening doesn't seem to be the problem). The file I am using has 4 sentences in it. The cout is not displaying anything. Something appears to be going wrong from after the file opening to the strings not going into the array.
There are two problems at line 20. The first, the line ends with a semicolon.
that makes it an empty loop
1 2
while(!in_stream.eof())
; // this is the body of the loop
The other problem is that it's a bad idea to loop on eof. This can be the cause of logic errors, such as infinite loop, or processing the last record more than once.
It's best to put the read operation inside the loop condition:
while (getline(in_stream,strings1[i]))
Here, the program also checks that the array capacity is not exceeded: