Hi, I've been wondering if there's a way to show only some part of a file when it reaches a limit, i.e I have this code that shows the latest orders of a restaurant, so every time that an order is made the program saves it to a file.
But I don't know if is possible to show only the last 10 or 15 orders
1) If the latest orders are at the start of the file, then it's easy - just maintain a count of the number of orders you've printed, and stop printing when you've done the first 15.
2) Otherwise, you'll probably need to read the whole file into memory first, identify the latest 15 orders, and then print those 15 out.