0% found this document useful (0 votes)
10 views

files - Replit1

The document contains a C program designed to list files in a directory. It includes essential code components such as including necessary libraries, opening the current directory, reading its contents, and printing the file names. The program handles errors related to directory access and ensures proper closure of the directory stream.

Uploaded by

23b01a1253
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

files - Replit1

The document contains a C program designed to list files in a directory. It includes essential code components such as including necessary libraries, opening the current directory, reading its contents, and printing the file names. The program handles errors related to directory access and ensures proper closure of the directory stream.

Uploaded by

23b01a1253
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

10/31/23, 12:08 PM files - Replit

files Invite Deploy

Search list_files.c consumer.c producer.c Console Shell

list_files.c ...
Files
1 // Reg.No:22b01a12e6 Name:R.hasmitha
a.out 2 // Experiment No:7
3 // Write a C Program to list files in
consumer.c
adirectory.
list_files.c 4 #include <dirent.h>
5 #include <stdio.h>
producer.c
6 ⌄ int main() {
7 struct dirent *de;
8 DIR *dr = opendir(".");
9⌄ if (dr == NULL) {
10 printf("Could not open current
directory");
11 return 0;
12 }
13 de = readdir(dr);
14 ⌄ while (de != NULL) {
15 printf("%s\n", de->d_name);
16 de = readdir(dr);
17 }
18 closedir(dr);
19 }
Tools

AI Deployments Authentication

Start Pro trial


Chat Code Search Console
Help

https://replit.com/@pravallikas9966/files 1/1

You might also like