0

argv字符串的 SAC 数组,还是传统的 C 字符串数组?

文档中有CommandLine.sac,但我不知道如何使用 SAC 的 API。

4

2 回答 2

1

In version (1.0) you can use the argv(1) function.

$ 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
于 2015-03-21T23:51:18.840 回答
0

SAC 两者都不做(实际上更糟):SACargv()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
于 2011-10-27T00:04:58.457 回答