#include<dirent.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/stat.h>
int main ()
{
struct dirent **namelist;
int i,j;
char userd[20];
struct stat statBuf;
printf("Enter a directory %s\n",userd);
scanf("%s",&userd);
printf("the dir is %s\n",*userd);
i=scandir(".",&namelist,0,alphasort);
printf("enter a directory name %s",*userd);
printf("scandir returned i=%d\n",&i);
if (i<0)
perror("Scandir failed to open directory I hope you understand \n");
else
{
for(j=0;j<i;j++)
{
printf("j=%d i=%d %s\n",j,i,namelist[j]->d_name);
// lstat
free(namelist[j]);
}
}
free(namelist);
}
Can some one help to understand why am I getting warning in above code?