• C

put file names in array

threre were some answers to my questions till now - no one was working
i need it for "c" program in windows!!!!!!!!

i get a  path of a directory called
"path_files" in a string
the function should read all the *.wrl files in the folder and put the names of the wrl files in an array of strings called
char **filebd;
i dont know how many files are in the folder.
i need to count them and put them in int - NO_OF_FILES
i need the function from the beginning including:
1)pointers declerations
2)malloc of the array of strings
3)making loop on all files and putting all the names in the array
4)especially 3!!!!!!

smbdy wrote

#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>

int main(){
    DIR* d;
    size_t cur_size=0;
    size_t max_size=12;
    char** dirlist=(char**)malloc(max_size*sizeof(char*));
    struct dirent* dentry;
    size_t namelen;
    int i;
        fprintf(stderr,"Cannot open dir '.'");
        namelen = strlen(dentry->d_name);
            continue; /* Skip entry */
        dirlist[cur_size] = (char*) malloc(namelen+1);
            max_size *= 2;
        printf("Entry #%d: %s\n",i,dirlist[i]);
    return 0;
 in windows... while compiling it retuns errors!!!
what is #include <dirent.h>?????
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

i dont think this code will work on windows.
you should consder reding from :
and coding around a bit
then u can post your code for further consideration by people here

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
and yes, you dont need to keep creating a new question every time. just use
one single thread.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.