Array and files

Hi again, this is the last part of my program that is confusing me (Im probably over looking something obvious though)

I can read from a user selected file, but I need the array contents to the the numbers in the file so I can find the longest increasing sequence.

This is what I have so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
int main()
{
    string fileBench;
    string line;
    
    cout<<"Please enter the bench file you wish to use: "<<endl;
    getline(cin, fileBench);
    
    ifstream bench ( fileBench.c_str() );
    if (bench.is_open())//testing to make sure I can read the user specific file
    {
                        while(! bench.eof())
                        {
                                getline(bench,line);
                                cout<<line<<endl;
                        }
                        bench.close();
    }//end testing
    else cout<<"Unable to open file"<<endl;
     
    
    
    int a[] = { ????? };//not sure how to give it the right information.
	vector<int> seq(a, a+sizeof(a)/sizeof(a[0]));
	vector<int> lis = find_lis(seq);


This is the last step for me, so any help is greatly appreciated.
Hi, just want to confirm what you are trying to do.

I think you are trying to read a file (specified by the user) which contains a series of numbers. You then want to process that set of numbers to find the longest increasing sequence.

Currently you can open and read the file, and are outputting the file to screen to validate that.

It looks like the numbers are integers, and the file contains one number per line.

Is this right?
Topic archived. No new replies allowed.