I have found the problem .Now It works great. The if statemenet is updated.
int listFilesIndir(char *currDir)
{
struct dirent *direntp;
DIR *dirp;
int x ,y =0 ;
if ((dirp = opendir(currDir)) == NULL)
{
perror ("Failed to open directory");
return 1;
}
while ((direntp = readdir(dirp)) != NULL)
{
printf("%s\n", direntp->d_name);
if(direntp->d_type == DT_DIR)
y++;
}
printf("direc Num (except parent and curr) : %d\n",y-2 );
while ((closedir(dirp) == -1) && (errno == EINTR)) ;
return 0;
}