Untitled

                Never    
C
       
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char* dirent_type_to_str(unsigned char dirent_type) {
  switch (dirent_type) {
  case DT_DIR:
    return "Dir";
  case DT_REG:
    return "File";
  }

  printf("DEBUG: Unknown type %x\n", dirent_type);
  return "Unk";
}


char* find(char* dirr,char simv)
{

  char name[1000]="";

  DIR *dir;
  struct dirent *entry;
  dir = opendir(dirr);
  if (!dir) 
  {
    perror("diropen");
    exit(1);
  }

  int sch=0;
  while ( (entry = readdir(dir)) != NULL)
  {

    if(strstr(name,"txt")) 
      return name;

    if(dirent_type_to_str(entry->d_type)=="Dir")
    {
      if(strncmp(entry->d_name,".",1)==0 || strncmp(entry->d_name,"..",2)==0)
        continue;
      char helpstr[100];
      strcpy(helpstr,dirr);
      strcat(helpstr,"/");
      strcat(helpstr,entry->d_name);

      strcpy(name,find(helpstr,simv));

      strcpy(helpstr,name);
      strcpy(name,entry->d_name);
      strcat(name,"/");
      strcat(name,helpstr);
    }
    else if(entry->d_name[0]==simv && entry->d_name[1]=='.')
    {
      strcpy(name,entry->d_name);
    }
  }
  closedir(dir);
  return name;
}


int main() 
{
  char dirr[1000]="./tmp\0";
  char str[20];
  scanf("%s",str);
  int i;
  freopen("result.txt", "w", stdout);

  for(i=0;i<strlen(str);i++)
  {
    printf("./tmp/%s\n",find(dirr, str[i]));
  }

  return 0;
}

Raw Text