且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检查文件是否在C特定类型

更新时间:2023-11-28 22:03:58

简单检查,如果文件扩展名是 .H ,是这样的:

Simply check if the file extension is .h, something like:

const char *ext = strrchr (entry->d_name, '.');     
if ((ext != NULL) && (!strcmp (ext+1, "h"))) {
     // header file
}

Ofcourse,请注意,这是假定所有的头文件,有一个 .H 扩展,这可能会或可能不会是真实的,C标准并不要求头文件必须有一个 .H 扩展。

Ofcourse, note that this assumes all your header files have an .h extension, which may or may not be true, the C standard does not mandate that header files must have an .h extension.