Enter your email address & Win:

System Software Lab Programs ( UNIX Programs ) – 6b

// June 6th, 2009 // Educational, Engineering, Unix and System Software Lab // Written by sandeephegde

-->

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

[Click Here to get other programs by email ]

………………………………………………………………………………………………………………………….
PART -B

………………………………………………………………………………………………………………………….

6b) C program that accepts a valid directory names as a command line argument and lists all the files in the given directory as well as all  the subsequent subdirectories. (The solution can be recursive or nonrecursive).

#include<stdio.h>
#include<ftw.h>
int recursive(const char *dir,const struct stat *name,int type)
{
if(type==FTW_D)
printf(“\n Directory->%s”,dir);
else if(type==FTW_F)
printf(“\nFile->%s”,dir);
return 0;
}

int main(int argc,char *argv[])
{
int depth=5;
ftw(argv[1],recursive,depth);
printf(“\n”);
return 0;
}

[Click Here to get other programs by email ]


If you enjoyed this post, make sure you subscribe to my RSS feed!

Related posts:

  1. System Software Lab Programs ( UNIX Programs ) – 3b
  2. System Software Lab Programs ( UNIX Programs ) – 5b
  3. System Software Lab Programs ( UNIX Programs ) – 7b
  4. System Software Lab Programs ( UNIX Programs ) – 3a
  5. System Software Lab Programs ( UNIX Programs ) – 4b
blog comments powered by Disqus
Get Adobe Flash playerPlugin by wpburn.com wordpress themes