Is it possible to print files in a directory with their full path?
Expected output: C:\Users\Gadr\Desktop\Text
Actual output: Text
Code:
di = opendir("C:\\Users\\Gadr\\Desktop"); //specify the directory name
while ((dir = readdir(di)) != NULL)
{
ptr1 = strtok(dir->d_name, ".");
ptr2 = strtok(NULL, ".");
if (ptr2 != NULL)
{
retn = strcmp(ptr2, "txt");
if (retn == 0)
{
printf("%s\n", ptr1);
}
}
}