对目录操作

      DIR* dir = opendir(strPath);
      if (dir == NULL) {
          perror("opendir err");
          return -1; 
      }   
      char bufline[1024] = {0};
      struct dirent* dent = NULL;
      while((dent=readdir(dir)))
      {   
          struct stat sb; 
          stat(dent->d_name,&sb);
          if(dent->d_type == DT_DIR)
          {   
              memset(bufline,0,sizeof(bufline));
              sprintf(bufline,"<li><a href='%s/'>%32s<a>  %8ld</li>",dent->d_name,dent->d_name,sb.st_size);
              printf("%s\n",bufline);
          }   
          else if(dent->d_type == DT_REG)
          {   
              memset(bufline,0,sizeof(bufline));
              sprintf(bufline,"<li><a href='%s'>%32s</a>  %8ld</li>",dent->d_name,dent->d_name,sb.st_size);
              printf("%s\n",bufline);
          }   
      }  
上一篇:ZJNU1178 完全背包【基础算法・动态规划】——中高级


下一篇:洛谷入门 dp专题