How to I run the debugger on a C++ project and pass command line args

I have a sample C++ program. How do I set it up so that when I Run or Debug, I can specify the command line args to pass to the program? I can run the program from the shell and pass args just fine. I can also run gdb from the shell and pass the args that way. What I want to be able to do is pass command line args when I press the “Run” button or use the debugger. I haven’t found a way to do that.

Here is my test program:

#include <iostream>

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

  for (int i = 0; i < argc; ++i) {
      std::cout << "Argument " << i << ": " << argv[i] << std::endl;
  std::cout << "Hello World!\n";
1 Like

Hello @mikenoel, welcome to Replit Ask!

You can add command args by:

  1. Pressing the … in the file pane
  2. Pressing Show hidden files
  3. Pressing the .replit file
  4. Change the second line from ./main to ./main whatever args you want.
1 Like

Thanks I got this to work for running. I haven’t yet figured out how to make this work for debugging. I’ve tried making changes in the debugger.interactive.launchMessage.arguments section (the arg array and the program property) but haven’t found the recipe that makes it work. Is there another property that I could add to that section to get the args in?

1 Like

I’m a tad late but for anyone looking for the debugger, you can find it under tools in the bottom left corner of the workspace.