argv
是字符串的SAC数组,还是传统的C字符串数组?
文档中有CommandLine.sac,但我不知道如何使用SAC的API。
答案 0 :(得分:1)
在版本(1.0)中,您可以使用argv(1)函数。
$ cat args.sac
use StdIO: all;
use Array: all;
use CommandLine: all;
int main() {
printf("Test: %s\n", argv(1));
return(0);
}
$./args hello
$ Test: hello
答案 1 :(得分:0)
SAC既不(实际上更糟):SAC在argv()
模块中提供CommandLine
,返回一个包含所有参数连接的字符串:
$ cat args.sac
use StdIO: all;
use Array: all;
use CommandLine: all;
int main() {
printf("%s\n", argv());
return(0);
}
$ sac2c -o args args.sac
$ ./args a b c
./args a b c