469,645 Members | 1,984 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Regarding fopen and chmod



when i execute the following code both lakshmi and sri gets printed,later
if i give pwd in the path /home/tcsbasr/CFILES the following statement is

"pwd: cannot determine current directory!"

if i give ls the below statement is displayed.

".: Permission denied"

Please let me know why the above statements are getting printed.

Expand|Select|Wrap|Line Numbers
  1. void main()
  2. {
  4.         char d1[256];
  5.     char d[30]="/home/tcsbasr/CFILES/";
  6.     FILE *fp1;
  8.     if(chmod(d,777)==0)
  9.     printf("lakshmi");
  11.     fp1=fopen("/home/tcsbasr/CFILES/y.c","w");
  12.     if(fp1==NULL)
  13.     printf("sri");
  15. }    

May 18 '07 #1
1 12781
1,251 Expert 1GB
777 is not what you want. You want 0777. Having a leading 0 make the
number be interpreted as an octal number.

May 18 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by bird | last post: by
9 posts views Thread by monomaniac21 | last post: by
2 posts views Thread by Joseph S. | last post: by
8 posts views Thread by FFMG | last post: by
16 posts views Thread by Hans Fredrik Nordhaug | last post: by
3 posts views Thread by IamtheEvster | last post: by
20 posts views Thread by cscorley | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.