Read the file sequentially from beginning to end, counting lines as you go along. If you want to read the 2d line then you will have to read lines 1 and 2. It is not possible to skip to a specific line in a text file.
int i = 0;
int line = 0;
int number = 0;
char c = '\0';
//Make sure your file is opened in binary mode when manipulating file pointers
cout << "Enter line number to read from file: ";
cin >> number;
//Search character by character for new line
//Increment counter when "new lines" are found.
if(c == '\n')
}while(line != number && infile.good());
//Set 'get' ponter to beginning of desired line to read
//Get the line.
Like ancient dragon says, there is no real automatic way to find where you want to be in the file without reading your way through it. Unless you already no exactly how many characters each line contain, and they all will always contain the same about of characters at all times, then you can just seekg() to the specific line.. but this is a very rare case.
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.