C programming

Showing posts with label directory show. Show all posts
Showing posts with label directory show. Show all posts

Wednesday, March 16, 2016

c program to print the names of all the files in current directory

#include<stdio.h>
#include<dirent.h>
void main()
{
  DIR *d;
 struct dirent *dir;
 d=opendir("."); //pointing to current directory
 if(d)
  {
   while((dir=readdir(d))!=NULL)
   {
    printf("\n%s",dir->d_name);
   }
   closedir(d);
  }
 }

output
abc.txt
hello.txt
program1.c
newhello.txt
Posted by Dinesh Agrawal at 7:52 AM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: C, C program, directory show, dirent.h, structure in c
Older Posts Home
Subscribe to: Posts (Atom)

About Me

My photo
Dinesh Agrawal
View my complete profile

Blog Archive

  • ▼  2016 (61)
    • ▼  June (9)
      • C program to understand the concept of initializat...
      • C program to make two matrix dynamically and show ...
      • C program to calculate GCD (greatest common diviso...
      • C program to save and retrieve records from extern...
      • c program to find factorial of a number without us...
      • C program to select elements from three given arra...
      • c++ program to show operation on time, add seconds...
      • C program to check given number in strong number o...
      • c program to count number of 1 in binary represent...
    • ►  May (14)
    • ►  April (15)
    • ►  March (23)
Simple theme. Theme images by fpm. Powered by Blogger.