So, hello againnnn, this is the problem for this week:
Create a function that receives as parameter the name of a file (this would be a string value like data.txt) and your function counts the number of lines and the number of characters in the file which it returns as a single value (but with two values). You will want to look at how to create/define and return a struct value from a function and how to open and read text files line by line.
So, how do I start???
First of all I include to new libraries :
- fstream: To be able to read a file.
- String: To use my get line function.
Then I declare my to variables «palabras and lineas» with a value of cero, then I make that my program will make a text file called texto.txt and then I put my if stream because we are going to put things on the program in other words «if = in, ofs= out».
Then I make to open my file with open and the name of my file, and what would happened if it fail and to do that while is open and its going to add one value to lineas and palabras.
I really don’t know how to explain it right because if you don’t know so much things you will never know what I am doing. So read your textbook and search information on internet about this problem, because it was a hard one.
See you laterrrrr.
Image from: https://clipartfest.com/categories/view/382647a840319bed4aa74f8b873e6b3c85a45d91/open-book-with-words-clipart.html