Question: I am trying to hardcode arguments that are passed to the [OpenCV Command Line Parser](http://%20https://docs.opencv.org/3.0-beta/modules/core/doc/command_line_parser.html). In the [object\_detection file](https://github.com/opencv/opencv/blob/master/samples/dnn/object_detection.cpp), I have added the code as such, so that I do not have to enter the file name via command-line: 

**Line 40-48:**

```
void drawPred(int classId, float conf, int left, int top, int right, int bottom, Mat& frame);

void callback(int pos, void* userdata);

int main(int argc, char** argv)
{
    // This line added below:
    argv[1]="-input /home/Videos/test.mp4";

    CommandLineParser parser(argc, argv, keys);
    parser.about("Use this script to run object detection deep learning networks using OpenCV.");
    if (argc == 1 || parser.has("help"))

```

OpenCV skips using this file, and switches to camera instead. How can I hardcode the arguments, before they are passed to the Command Line Parser ?

Answer: 
The problem is that `argc,argv` are an old-style C mechanism. You can't simply insert a value in the C array `char**`. Instead, you must create a new array with one extra element. (Your existing code *overwrites* `argv[1]`)

Now there's more unusual stuff. `argv` is an array with `argc+1` elements, the last one of which is `nullptr`. Since you're inserting a new element, you must create an `char*[argc+2]*`, copy all `argc` elements, append the pointer to your string, and then terminate the new array with `nullptr`.

You can now pass the new array and `argc+1` to `CommandLineParser`.
The goal of argc and is to pass argument t"-input /home/Videos/test.mp4");
 argv[2] = NULL;hrough the main, if you are using a GNU / UNIX distribution, just pass argument like it:

```
argc = 2
argv[1] = strdup("-input /home/Videos/test.mp4");
argv[2] = NULL;

CommandLineParser parser(argc, argv, keys);
parser.about("Use this script to run object detection deep learning networks using OpenCV.");
if (argc == 1 || parser.has("help"))

```

or just use "normal" way and pass argument through our binary, like

> 
> ./a.out "-input /home/Videos/test.mp4"
> 
> 
>