小编Eri*_*mba的帖子

当声明为结构体字段内的字段时, void (func)(void) 和 void (*func)(void) 之间的区别?

所以我被告知这些几乎彼此相同

void function1 (void(func)(int), int arg){
    func(arg);
}

void function2 (void(*func)(int), int arg){
    func(arg);
}
Run Code Online (Sandbox Code Playgroud)

当我执行这个时,它不会抛出任何错误。

void print_plus_1(int p)
{
    printf("p=%d\n", p+1);
}

void print_plus_2(int p)
{
    printf("p=%d\n", p+2);
}


int main(void)
{
    function1(print_plus_1, 1);
    function2(print_plus_2, 1);

}
Run Code Online (Sandbox Code Playgroud)

但是,当我在结构内初始化相同的 void (func) (int) 与 void (*func) (int) 模式时

struct foo
{
    void (func1)(int);
    void (*func2)(int);
};


void print_plus_1(int p)
{
    printf("p=%d\n", p+1);
}

void print_plus_2(int p)
{
    printf("p=%d\n", p+2);
}

int main(void)
{
    struct foo f;
    f.func1 = print_plus_1;
    f.func2 = …
Run Code Online (Sandbox Code Playgroud)

c

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

使用 powershell 获取包含超过 700 万个项目的目录中的文件

这就是我目前正在尝试执行的。

$folderPath = 'M:\abc\WORKFORCE\Media\Attachments' 
 
Write-Host "Executing Script..." 
 
foreach ($file in Get-ChildItem $folderPath -file)
{
       # execute code 
}
Run Code Online (Sandbox Code Playgroud)

然而,当我执行 powershell 脚本时,它冻结了。这样已经一个小时了。我假设这可能是因为该目录中有超过 800 万个项目。有没有更有效的方法来移动这些物品?等待是我唯一的选择吗?或者由于目录太大而根本无法使用 powershell 执行此操作?

powershell

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

标签 统计

c ×1

powershell ×1