/* C Program to get file attributes */
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
char fname[150];
unsigned attrib;
clrscr();
printf("Enter a file name: ");
scanf("%s",fname);
if(_dos_getfileattr(fname,&attrib)!=0)
perror("\nUnable to get attributes!");
else
{
if(attrib&_A_RDONLY)
printf("\n%s is read only.\n",fname);
if(attrib&_A_HIDDEN)
printf("\n%s is hidden.\n",fname);
if(attrib&_A_SYSTEM)
printf("\n%s is system file.\n",fname);
if(attrib&_A_SUBDIR)
printf("\n%s is directory.\n",fname);
if(attrib&_A_ARCH)
printf("\n%s is an archive file.\n",fname);
}
getch();
}
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
char fname[150];
unsigned attrib;
clrscr();
printf("Enter a file name: ");
scanf("%s",fname);
if(_dos_getfileattr(fname,&attrib)!=0)
perror("\nUnable to get attributes!");
else
{
if(attrib&_A_RDONLY)
printf("\n%s is read only.\n",fname);
if(attrib&_A_HIDDEN)
printf("\n%s is hidden.\n",fname);
if(attrib&_A_SYSTEM)
printf("\n%s is system file.\n",fname);
if(attrib&_A_SUBDIR)
printf("\n%s is directory.\n",fname);
if(attrib&_A_ARCH)
printf("\n%s is an archive file.\n",fname);
}
getch();
}
No comments:
Post a Comment