# How to make root file parse arguments from command line?

**URL:** <https://root-forum.cern.ch/t/how-to-make-root-file-parse-arguments-from-command-line/63780>\
**Category:** Newbie\
**Created:** [June 22, 2025, 5:12pm UTC](https://root-forum.cern.ch/t/how-to-make-root-file-parse-arguments-from-command-line/63780 "2025-06-22T17:12:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oswaldo\_Cardenas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oswaldo_cardenas/32/39039_2.png) [@Oswaldo\_Cardenas](https://root-forum.cern.ch/u/Oswaldo_Cardenas)\
**Post date:** [June 22, 2025, 5:12pm UTC](https://root-forum.cern.ch/t/how-to-make-root-file-parse-arguments-from-command-line/63780/1 "2025-06-22T17:12:57Z")

</div>

Hello,

As someone who has been learning both C++ and ROOT at the same time, one of the issues I am having trouble with is figuring out how to implement a way to parse arguments from the command line into my main function. Currently, I have my main function where I want to open a ROOT file, it looks like this

```auto
int main(int argc, char* argv[]) {

  //Parse arguments

  std::unique_ptr<TFile> myFile{TFile::Open(filename, "UPDATE")};

  //TFile full(fileName);
  fileIterator(myFile);
  return 0;
  //RNTupleMover();

```

I would like a way to input a root file from the command line and get its name. Thank you!  
_ROOT Version:_ 6.34.04  
_Platform:_ Windows  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [June 22, 2025, 5:24pm UTC](https://root-forum.cern.ch/t/how-to-make-root-file-parse-arguments-from-command-line/63780/2 "2025-06-22T17:24:43Z")

</div>

Hi Oswaldo,

This question is important but not really related to ROOT.  
You can access the arguments at the command line as elements of the `argv` array, i.e. `argv[0]`, `argv[1]`, …  
First hit on a popular web search engine: [link](https://stackoverflow.com/questions/3024197/what-does-int-argc-char-argv-mean)

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [June 23, 2025, 4:22pm UTC](https://root-forum.cern.ch/t/how-to-make-root-file-parse-arguments-from-command-line/63780/3 "2025-06-23T16:22:08Z")

</div>

I recommend [GitHub - CLIUtils/CLI11: CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.](https://github.com/CLIUtils/CLI11)

It’s header-only, so no need to do much extra compilation.
