how to check if directory/file exist using c/c++ | Unix Linux Forums | Programming

  Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

how to check if directory/file exist using c/c++

Programming


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-02-2006
steven88 steven88 is offline
Registered User
 
Join Date: Jan 2006
Last Activity: 3 January 2006, 1:56 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
how to check if directory/file exist using c/c++

Hi there,

how to check if directory/file exist using c/c++ under linux/unix. Thanks.

Steven
Sponsored Links
    #2  
Old 01-02-2006
vino's Avatar
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Join Date: Feb 2005
Last Activity: 9 April 2013, 8:19 AM EDT
Location: Sydney, Down Under
Posts: 2,847
Thanks: 0
Thanked 12 Times in 12 Posts
Use the stat call.


Code:
struct stat st;
if(stat("/tmp",&st) == 0)
        printf(" /tmp is present\n");

Sponsored Links
    #3  
Old 01-03-2006
steven88 steven88 is offline
Registered User
 
Join Date: Jan 2006
Last Activity: 3 January 2006, 1:56 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you!

vino,
Thank you very much.
Steven
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to check file exist in a directory or not sravan008 Shell Programming and Scripting 5 07-21-2011 01:57 AM
check the directory exist ust Shell Programming and Scripting 7 09-22-2008 08:49 PM
To check whether a directory is exist and if it is not, create it sabya Shell Programming and Scripting 3 09-20-2008 02:23 PM
How to check directory exist on servers weonpc Shell Programming and Scripting 2 03-06-2008 05:29 AM
how to check if directory/file exist using c/c++ steven88 Shell Programming and Scripting 1 01-02-2006 09:45 PM



All times are GMT -4. The time now is 09:36 AM.