[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


how to put files of folder in an array

Posted on 2004-10-26
Medium Priority
Last Modified: 2010-04-15
i have a function that returns the path of a directory in
char file_name;
i need to find how many *.wrl files are in the folder
and put in an array of strings called
all the wrl file names in the folder
such as:
all the files of the folder should be in the array, each in a different cell...
( i dont know how many cells are in the array...) - should make malloc...
Question by:niria
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 46

Accepted Solution

Kent Olsen earned 200 total points
ID: 12416917

You'll need an array of strings to hold the file names.  Better yet, an array of string pointers.  You'll also need to call findfirst() and findnext() to read through the filenames in the directory.   (These are standard functions available in both unix and windows programming.)

This sounds like it may be homework, so I'll get you through the string pointer table, and you research findfirst() and findnext().


char **FileNames = NULL;
int    FileCount = 0;

AddNameToList (char *Name)
  FileNames = (char **) realloco (FileNames ((FileCount+1) * sizeof (char *)));
  FileNames[FileCount++] = strdup (Name);


Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question