小编Got*_*irl的帖子

cd命令不能与execvp一起使用

#include <stdio.h>
#include <sys/types.h>
#include <string.h>

int main()
{
    char *ip;
    char *temp[10];
    pid_t pid;

    pid = fork();

    if (pid == 0) {
        int i = 0;

        do {
            gets(ip);

            temp[0] = strtok(ip, " ");
            while (temp[++i] != NULL) {
                temp[i] = strtok(NULL," ");
            }

            pid_t pid2;

            pid2 = fork();
            if (pid2 == 0) {
                execvp(temp[0], temp);
            }
        } while(strcmp(temp[0], "quit"));

        if (!strcmp(temp[0],"quit")) {
            return;
        }
    } else if (pid < 0) {
        fprintf(stderr,"error in creating child");
    } else if …
Run Code Online (Sandbox Code Playgroud)

c linux

2
推荐指数
1
解决办法
7029
查看次数

for循环的中间部分的目的

for(i = 0; str[i]; ++i)
    ++count[str[i]];

// Change count[i] so that count[i] now contains actual position of
// this character in output array
for (i = 1; i <= RANGE; ++i)
    count[i] += count[i-1];

// Build the output character array
for (i = 0; str[i]; ++i)
{
    output[count[str[i]]-1] = str[i];
    --count[str[i]];
}
Run Code Online (Sandbox Code Playgroud)

通常,for循环的中间部分有一些比较,但for这里的第一个循环只有一个表达式.你能告诉我那是什么意思吗?

c

2
推荐指数
1
解决办法
124
查看次数

将使用"+"在地图中保留我的订单?没有权利?

scala>  var test2 : Map[String , String] = Map("a"->"b","c"->"d")
test2: Map[String,String] = Map(a -> b, c -> d)

test2 = test2 + ("e"->"f" , "g"->"h")
test2: Map[String,String] = Map(a -> b, c -> d, e -> f, g -> h)
Run Code Online (Sandbox Code Playgroud)

等等.我想知道Map不应该保留插入顺序[为此目的我们有LinkedHashMap]那么为什么结果显示保存顺序?这仅仅是巧合还是不仅仅是满足于眼睛?

提前致谢!

scala scala-collections

1
推荐指数
1
解决办法
60
查看次数

标签 统计

c ×2

linux ×1

scala ×1

scala-collections ×1