--Originally published at Loading…
Hi!! Is almost the ending of this semester and I promised not to leave everything to the last minute… but here I am… doing all in the last minute.
Today I’m going to explain how I did the #WSQ09. To make this program I asked for help to my friend Jenifer Romero, she explained me everything, but the problem was that we did it on her Mac, so… I had to make some arrangements in order for it to work in my Windows computer.
This is what we had to do:
So for this assignment I would like to see you 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
The first thing I did was to add the two necessary libraries <fstream> & <string>. Then, for make the “it returns as a single value (but with two values)” part, I added a struct that I called datos, which stores two int, l (for lines) and c (for the characters). Next, in my function (func) which receives the string url (or ruta) and called the struct. After that I wrote ifstream archivo(ruta.c_str(), ios::in) it associates it with the file name and opens it. I established my variables (at the final I don’t use the char car, ‘cause Ken helped me to do the same with less), and wrote a while for do the things until the
Continue reading "Multipart Data & Files"