Docstoc

unix programming 12

Document Sample
unix programming 12 Powered By Docstoc
					DATE:                                                       PAGE NO:


//Program for displaying contents in a directory




#include"dirent.h"

#include"stdio.h"

#include"unistd.h"

#include"fcntl.h"//function control

#include"sys/stat.h"

#include"sys/types.h"




int main()

{

    DIR *p;

    struct dirent *q;

    p=opendir("temp");



    if(p==NULL)

    {

           printf("error");

           return 0;

    }



    else

           printf("directory opened successfully\n\n");

    printf("files are:\n");

UNIX LAB                                                  10A91A0570
DATE:                                      PAGE NO:


      while(q=readdir(p))

      {

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

      }

      closedir(p);

      return 0;

}




output:

directory opened successfully



files are:

one

two

.

..



//.=>current working directory

..=>parent working directory//




UNIX LAB                                 10A91A0570

				
DOCUMENT INFO
Shared By:
Tags:
Stats:
views:3
posted:9/22/2013
language:
pages:2