This language bar is your friend. Select your favorite languages!

Idiom #60 Read command line argument

Assign to x the string value of the first command line parameter, after the program name.

void main(int argc, char *argv[])
    char *x = argv[1];
int main(int argc, char *argv[])
 vector<string> args(1 + argv, argc + argv);

 string x =;
static void Main(string[] args)
    string x = args[0];
auto x = args[1];
main(args) {
  var x = args[0];
  character(len=:), allocatable :: x
  integer :: n
  call get_command_argument (1, length=n)
  allocate (character(n):: x)
  call get_command_argument (1, x)
import "os"
x := os.Args[1]
x <- return.head =<< System.Environment.getArgs
let x = process.argv[2]
String x = args[0];
x = arg[1]
$x = $argv[1];
  _x: String;
  _x := ParamString(1);
$x = $ARGV[0];
import sys
x = sys.argv[1]
x = ARGV.first
use std::env;
let first_arg = env::args().skip(1).next();

let fallback = "".to_owned();
let x = first_arg.unwrap_or(fallback);

Do you know the best way to do this in your language ?
New implementation...

Idiom created by