0

So basically im stuck on how to pass in a file name that contains a set of value and an int that informs the program how many values are in the file from the command line.

like I want to be able to do $> ./program file.txt 8

8 would be how many values are in the file.txt.

what would the code look like for that in C++

heres what I have so far but its nowhere near working :(

int main(int argc, char *argv[])
{
    ifstream file;
    int size;
    int arr[size],val;
    for(int i=0;i<size;i++)
    {
        cin>>val;
        arr[i] = val ;
    }

0 Answers0