Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/164.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;比较2个文件夹中的文件_C++ - Fatal编程技术网

C++ C++;比较2个文件夹中的文件

C++ C++;比较2个文件夹中的文件,c++,C++,我正在为两个文件夹的内容生成哈希。然后我想比较所有的散列,一次一个文件夹a和文件夹b的所有内容 如果他们在每个文件夹中都有相同的文件,这就行了,但我计划在文件夹B中有大约500个文件,在文件夹A中可能有5-10个。我现在使用的循环如下 for (i=0;i<nbfiles1;i++) { printf("file1: %s\n", files1[i]); for (j=0;j<nbfiles2;j++) { printf(" file2:

我正在为两个文件夹的内容生成哈希。然后我想比较所有的散列,一次一个文件夹a和文件夹b的所有内容

如果他们在每个文件夹中都有相同的文件,这就行了,但我计划在文件夹B中有大约500个文件,在文件夹A中可能有5-10个。我现在使用的循环如下

for (i=0;i<nbfiles1;i++)
{
    printf("file1: %s\n", files1[i]);
    for (j=0;j<nbfiles2;j++)
    {
        printf("    file2: %s\n", files2[j]);
        cs=ph_audio_distance_ber(hashes[i],lens[i],hashes2[j],lens2[j],threshold,block_size,Nc);
        double max_f = 0.0;
        for (index=0;index<Nc;index++)
        {
            if (cs[index] > max_f)
                max_f = cs[index];
        }//end if
        printf("    cs = %f\n", max_f);
    }//end for
}//end for

for(i=0;istd::bad_alloc异常在您没有enouth内存或尝试分配无效大小时引发。

检查完成内存分配的代码,如果找不到,请向我们展示更多信息。

给出代码的开头可能会有所帮助,但数组初始化肯定存在一些问题。没有什么明显的问题(至少对我来说)在您发布的代码中-问题可能在其他地方。它实际上在哪里崩溃?您是否尝试使用调试器运行它并查看哪里出错了?file1:/home/chriss/A/01 the Hollow.mp3 file2:/home/chriss/B/01 the Package.mp3 file2:/home/chriss/B/10 Pet.mp3它迭代前11首曲目,然后终止。cs=0.251718 file2:/home/chriss/B/11 Lullaby.mp3在抛出“std::bad_alloc”what():std::bad_alloc fish:Job 1.”/test/home/chriss/A/home/chriss/B”实例后调用terminate通过信号SIGABRT终止(Abort),您可以捕获异常并获取有关错误的更多信息