This language bar is your friend. Select your favorite languages!
Select your favorite languages :
- Or search :
void main(int argc, char *argv[])
{
char *x = argv[1];
}
argv[0] would be the program name. See §5.1.2.2.1 Program startup in linked doc n1570.pdf .
character(len=:), allocatable :: x
integer :: n
call get_command_argument (1, length=n)
allocate (character(n):: x)
call get_command_argument (1, x)
public static void main(String[] args) {
if (args.length != 0) {
String x = args[0];
}
}
In most JVM implementations, the `args` parameter will be non-null.
let x = env::args().nth(1).unwrap_or("".to_string());
We get the 1st element using the nth method and we fallback to an empty string if no arg was found.
let first_arg = env::args().skip(1).next();
let fallback = "".to_owned();
let x = first_arg.unwrap_or(fallback);
The first CLI argument may not be present. We fall back to an empty string.