Find the answer to your Linux question:
Results 1 to 4 of 4
I find everytime, one of my program call fopen, it can not open the existing file, but another program can. The errno of fopen is 2, but I don't know ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2005
    Posts
    19

    fopen errno message


    I find everytime, one of my program call fopen, it can not open the existing file, but another program can.
    The errno of fopen is 2, but I don't know what '2' means for fopen, please give me some advice.
    Thanks.

  2. #2
    Linux Guru sdousley's Avatar
    Join Date
    Feb 2004
    Posts
    1,790
    What language are you using? there's a few i can think of that have the fopen function
    "I am not an alcoholic, alcoholics go to meetings"
    Registered Linux user = #372327

  3. #3
    Linux User
    Join Date
    Aug 2005
    Location
    Italy
    Posts
    401

    C...

    If you C use strerror(int errno) declared in string.h

    Code:
    #include ....
    
    if &#40;fopen&#40;"foo", "w+"&#41; < 0&#41;
         fprintf&#40;stderr, "Error&#58; %s.\n", strerror&#40;errno&#41;&#41;;
    It will be printed a human readable description of the error. See also perror...
    When using Windows, have you ever told "Ehi... do your business?"
    Linux user #396597 (http://counter.li.org)

  4. $spacer_open
    $spacer_close
  5. #4
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    errno 2 is ENOENT, No such file or directory. I suspect the path you're specifying in your code is wrong. If you post the relevant snippet we can advise further.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •