So far I've tested my program with the .txt files in my computer and it seems that my program works. But I want to see if YOU can open any .txt file in your computer with this program
If the file is larger than 1000 lines, then line 35 will overrun the tail_of_file array. At that point the behavior becomes undefined. To see this, try running it with a very large input file and you will probably find that the program crashes.
You should check out Circular Buffers ( also called Ring Buffers ). I couldn't find a simple example online, but the general idea is that if you want to see the last ten lines of a file, you make your array of size ten. When you reach the 11th line, you don't need the first element in the array anymore ( the first line ) so you overwrite it: