Solved

how to put files of folder in an array

Posted on 2004-10-26
167 Views
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
"file_body"
all the wrl file names in the folder
such as:
filebd[0]="cube.wrl"
filebd[1]="triangle.wrl"
...
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...
thnx
0
Question by:niria
    1 Comment
     
    LVL 45

    Accepted Solution

    by:

    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().

    Kent



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


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


    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
    This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
    The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
    The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

    856 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now