Writing SD card file names in array with sdFat lib

hi,
I am doing a project where i Want to make a directory of files in sd card and want to print them on lcd so that user can choose whichever he want.
But the problem is I need to put those name in char array first so that i can print it on touch screen.

/*
 * Print size, modify date/time, and name for all files in root.
 */
#include <SPI.h>
#include <SdFat.h>

// SD chip select pin
const uint8_t chipSelect = SS;

// file system object
SdFat sd;

SdFile file;
//------------------------------------------------------------------------------
void setup() {
  Serial.begin(9600);
  while (!Serial) {} // wait for Leonardo
  delay(1000);
  Serial.println();

  // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
  // breadboards.  use SPI_FULL_SPEED for better performance.
  if (!sd.begin(chipSelect, SPI_HALF_SPEED)) {
    sd.initErrorHalt();
  }

  // open next file in root.  The volume working directory, vwd, is root
  while (file.openNext(sd.vwd(), O_READ)) {
    file.printFileSize(&Serial);
    Serial.write(' ');
    file.printModifyDateTime(&Serial);
    Serial.write(' ');
    file.printName(&Serial);
    if (file.isDir()) {
      // Indicate a directory.
      Serial.write('/');
    }
    Serial.println();
    file.close();
  }
  Serial.println("Done!");
}
//------------------------------------------------------------------------------
void loop() {}

This was the example code in lib for printing available files but how to store them on char array instead of printing them on serial?
Can any one could guide me on it?

but how to store them on char array instead of printing them on serial?

What char array? You don't HAVE a char array.

@Pauls, I haven't understand how to call this function. I tried following but due to lack of knowledge failed miserably, here is a code i have tried with error.

/*
 * Print size, modify date/time, and name for all files in root.
 */
#include <SPI.h>
#include <SdFat.h>
char Name[16][6];
// SD chip select pin
const uint8_t chipSelect = SS;

// file system object
SdFat sd;

SdFile file;
//------------------------------------------------------------------------------
void setup() {
  Serial.begin(9600);
  while (!Serial) {} // wait for Leonardo
  delay(1000);
  Serial.println();

  // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
  // breadboards.  use SPI_FULL_SPEED for better performance.
  if (!sd.begin(chipSelect, SPI_HALF_SPEED)) {
    sd.initErrorHalt();
  }

  // open next file in root.  The volume working directory, vwd, is root
  while (file.openNext(sd.vwd(), O_READ)) {
    file.printFileSize(&Serial);
    Serial.write(' ');
    file.printModifyDateTime(&Serial);

'SdFile::printModifyDateTime(char (*)[16][6])'


    
    Serial.write(' ');
    file.printName(&Serial);
//file.printName(&Name);// #ERROR:- error: no matching function for call to'SdFile::file.printName(char (*)[16][6])'
    if (file.isDir()) {
      // Indicate a directory.
      Serial.write('/');
    }
    Serial.println();
    file.close();
  }
  Serial.println("Done!");
}
//------------------------------------------------------------------------------
void loop() {}

I haven't understand how to call this function.

What function?

I tried following but due to lack of knowledge failed miserably, here is a code i have tried with error.

What error?

@pauls

What function?
What error?

I used same function and tried to pass Name array and faied.

/file.printName(&Name);// #ERROR:- error: no matching function for call to 'SdFile::file.printName(char (*)[16][6])'

Easiest way to have an array of strings is to make a struct/class with a string in it and just have an array of the structs:

struct StringThing //whatever you want to call it...
{
	char *str;
	
	StringThing( char *setT)
		: str(setT)
	{

	}
}

StringThing Name[2] { StringThing("Boring!"), {"blah blah"} }; //Either way works

//Inside whatever functions and junk
file.printName(Name[0].str); //Access the strings like this

The purpose of your code is unclear and you have some odd lines written.
I am not familiar with that sd library - From what I can see it is printing the file name to a stream, not a char array.

Have had a look at that library quickly -You should be using getName not printName

Sir I haven't find any getName function in this library can you show me example of get name function?

basically what i want is just store the name of open file in a character array ( as I know we can open a next file with file.openNext(sd.vwd(), O_READ) command. ). could you guys can guide me for this?

There are lfnGetName(), getName(), and getSFN() functions, defined in FatFileLFN.cpp and FatFileSFN.cpp. Which you use depends on whether you are using long file name, short file names, or haven't a clue.