79491298

Date: 2025-03-07 04:59:06
Score: 1
Natty:
Report link

#include <stdio.h>

#include <stdlib.h>

#include <dirent.h>

#include<conio.h>

int main(void) {

DIR *d;

struct dirent *dir;

char *directory_path = " "; // "." refers to the current directory

clrscr();

printf("\nEnter path of the directory...!\n");

printf("\For example: 'C:/TURBOC3/SOURCE' :\n");

scanf("%s",directory_path);

d = opendir(directory_path);

if (d) {

while ((dir = readdir(d)) != NULL) {

printf("%s\n", dir->d_name);

}

closedir(d);

} else {

perror("Unable to open directory");

return EXIT_FAILURE;

}

getch();

return EXIT_SUCCESS;

}

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: PRABHAKAR GATTU