void main(string[] args) {
string s = args[0].baseName;
}
S : String := (Simple_Name (Command_Name));
#ifdef _WIN32
#define PATH_SEP '\\'
#else
#define PATH_SEP '/'
#endif
int main(int argc, char* argv[])
{
char *s = strchr(argv[0], PATH_SEP);
s = s ? s + 1 : argv[0];
return 0;
}
int main(int argc, char* argv[])
{
std::cout << std::filesystem::path(argv[0]).filename() << '\n';
}
var path=Environment.CommandLine;
var s=Path.GetFileName(path);
var s = File(Platform.resolvedExecutable).uri.pathSegments.last;
program p
implicit none
character(len=:),allocatable :: s
integer :: stat,l,i,j,k
call get_command_argument (0,length=l)
allocate(character(len=l) :: s)
call get_command_argument (0,s,status=stat)
if (stat == 0) then
i=index(s,'/',back=.true.)
j=index(s,'\',back=.true.)
k=max(i,j)
if(k.ne.0)s=s(k+1:)
print *, "The program's name is " // trim (s)
endif
end program p
path := os.Args[0]
s = filepath.Base(path)
path, err := os.Executable()
if err != nil {
panic(err)
}
s = filepath.Base(path)
String s = System.getProperty("sun.java.command");
$s = $_SERVER['PHP_SELF'];
s := ExtractFileName(ParamStr(0));
let s = std::env::current_exe()
.expect("Can't get the exec path")
.file_name()
.expect("Can't get the exec name")
.to_string_lossy()
.into_owned();
fn get_exec_name() -> Option<String> {
std::env::current_exe()
.ok()
.and_then(|pb| pb.file_name().map(|s| s.to_os_string()))
.and_then(|s| s.into_string().ok())
}
fn main() -> () {
let s = get_exec_name().unwrap();
println!("{}", s);
}