时,我不知道哪里是我在程序的问题,我用一个debuger但它没有指定在哪个行是错误段错误检测的文件扩展名
#define _POSIX_SOURCE //pour nofile
#include <stdio.h>
#include <stdlib.h>
#include <magic.h>
int main (void)
{
const char *description;
magic_t cookie;
FILE* Texte= NULL;
if(NULL == (Texte = fopen("chaines", "r")))
{ // then fopen failed
perror("fopen failed for chaines for read");
exit(EXIT_FAILURE);
}
// implied else, fopen successful
cookie = magic_open(MAGIC_NONE);
description = magic_descriptor(cookie, fileno(Texte));
printf("%s\n", description);
return 0;
}
And this is my debuger result
Starting program: /home/hamza/Bureau/Projet_suffixe/suffixe_db
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7888e41 in ??() from /lib/x86_64-linux-gnu/libc.so.6
谢谢。
重新编译调试符号。 –
难道是'magic_open'在失败时返回'NULL'? –
检查magic_open()是否成功。如果是这样,请检查magic_descriptor()是否成功。 – nos