#include
#include
int main()
{
int mode;
/*check a files attributes*/
mode = access(“f:/cprojects/urls.txt”,0);
if(mode)
printf(“File does not exist.n”);
else
/*check if the file can be written to*/
mode = access(“f:/cprojects/urls.txt”,2);
if(mode)
printf(“File cannot be written.n”);
else
printf(“file can be written to.n”);
/*check if file can be read*/
mode = access(“f:/cprojects/urls.txt”,4);
if(mode)
printf(“File cannot be read.n”);
else
printf(“File can be read.n”);
/*check if afile can be read/written*/
mode = access(“f:/cprojects/urls.txt”,6);
if(mode)
printf(“File cannot be read/written to.n”);
else
printf(“File can be read/written to.n”);
return 0;
}
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.


















