file find

This is a discussion on file find within the C Programming forums, part of the General Programming Boards category; can we find out whether a file exists or not with out using the fopen command.......i am using the fopen ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    36

    file find

    can we find out whether a file exists or not with out using the fopen command.......i am using the fopen command and when it encounters a file that doesnt exists it gives me segmentation error
    i am using C in linux

  2. #2
    Registered User Azuth's Avatar
    Join Date
    Feb 2002
    Posts
    236
    http://faq.cprogramming.com/cgi-bin/...&id=1043284392
    When all else fails, read the faq.
    Demonographic rhinology is not the only possible outcome, but why take the chance

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >can we find out whether a file exists or not with out using the fopen command
    Not with any real precision. You can find out if opening the file fails by calling fopen though. A file open failure usually means that the file doesn't exist, so you can make a few assumptions and be happy.

    >it gives me segmentation error
    Would that be because you're trying to use the resulting null pointer?
    My best code is written with the delete key.

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    To find this infomation, you should look at the value of errno dirrectly after the fopen call. The function perror prints out this infomation somehow.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  2. #include header files or .cpp files?
    By DoctorX in forum C++ Programming
    Replies: 3
    Last Post: 12-23-2006, 11:21 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21