--Originally published at May The Code be With You
Hello, Young Padawans!
This time I bring you the third most difficult WSQ (in my opinion).
The WSQ09 ask us to open a text file, count how many lines doest it has, and how many characters.
When I first saw it I say “Whaaaat?! How am I supposed to do so?”. But with the help of Ken and my friend Adal, I found the way.
Well, first of all, is very important that you do some research by your own in google, about how to open files and about structures (are very handy in this assignament). Remember, as Ken said: “Stack Overflow and cplusplus.com are your friends”.
A structure is a format that let you storage several variables, even of different types, inside one concept.
And, you will also need the library <fstream>
As you can see in my code, I made a struct named “info” in wich, I saved 2 variables of “int” kind. After you research, you may see that there are some commands that let you do the exat thing you wanted to do, just like open the file, conunt the lines, and so and so. I hope yu get the syntaxis of this code.