How to pass const char * pointer to fts_open ()

How to go const char * path to fts_open? I would like to pass filePath.

+4
source share
2 answers

I assume that you want to know how to pass this single path to the argv (type char const ** ) fts_open . This parameter is described as follows:

ARGV

Is NULL a complete array of character pointers, naming one or more paths that make up the file hierarchy.

So, you need to create an array of length 2, whose elements are of type char* . Put your path in the first element and put NULL in the second element. Like this:

 char const *argv[] = { path, NULL }; 

Now you can pass argv to fts_open .

+3
source

The first argument to fts_open() is: "A NULL complete array of character pointers, naming one or more paths that make up the file hierarchy."

So you can pass this as follows:

 char *pathlist[2]; pathlist[0] = filePath; pathlist[1] = NULL; fts_open( pathlist, ...); 
0
source

Source: https://habr.com/ru/post/1403997/


All Articles