I want to know how can I use the line from a matrix as the source for a getline function. I have a matrix that stores several web pages. Each line of this matrix is the complete address of the web page and each row represents a single letter. What I must do is to read the web sites in my matrix one by one.
To get the web pages from the text file I use
1 2
ifstream file;
file.open("test.txt");
But I have no idea how to make the matrix my source for the getline.
If you need more explanations let me know. Oh and btw this my second month of programing so apart from some basic C++ we haven't learned all that much yet.
Yes I have that list, but I already stored its contents in a Matrix. Ok I suppose I'll go all the way with it. We are doing the first part of a page ranking algorithm (adapted for our level I suppose).
We have two matrices. The first one stores the contest of the text file. The second reads a web page from a first matrix then opens the web page found on the coresponding line and then searches it for links towards other web pages. What I don't know how to do is to read web page's address from the first matrix.
Ex: let's say I have "mysite.com" stored on the Store[i][] line in my Store matrix. I want to use "mysite.com" as a reading source for my getline() function. The only problem is that they only showed us how to stream contents from a file but not from a vector or a matrix.
The mechanics of downloading using HTTP is straight forward. You can do it yourself, or there are a few libraries kicking around that'll do it.
curl is a common Linux one
fetch is BSD one
I imagine v is a matrix, and v[i] gets the i-th string in it. If this is right, then you need to use c_str() to get a C-style string. I'm pretty sure opening a file requires it.