从网上看到的,于是赶紧记录下来。

 

 1 //头文件 
 2 #include "stdio.h" 
 3 #include "stdlib.h" 
 4 #include <sys/stat.h> 
 5 //代码 
 6 int main() 
 7 
 8     char* fileName = "aa.txt"
 9     struct _stat buf; 
10     int result; 
11     result = _stat( fileName, &buf ); 
12     if(_S_IFDIR & buf.st_mode){ 
13         printf("folder\n"); 
14     }else if(_S_IFREG & buf.st_mode){ 
15         printf("file\n"); 
16     } 
17 
18     return 0
19 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-07-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案