- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Program in C
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2005 09:30 PM
тАО07-06-2005 09:30 PM
Is there anyway I can write a program in C to check whether a file exist in a path?
regards
Henry
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2005 09:41 PM
тАО07-06-2005 09:41 PM
Re: Program in C
- Biswajit
- Tags:
- stat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-07-2005 12:12 AM
тАО07-07-2005 12:12 AM
Solution================
#include
#include
int main() {
struct stat bstat;
if (stat("filename", &bstat) < 0) {
fprintf(stderr, "file does not exist\n");
} else {
fprintf(stderr, "file does exist\n");
}
}
===========
-Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-07-2005 12:26 AM
тАО07-07-2005 12:26 AM
Re: Program in C
#include
main()
{
FILE *fp;
fp=fopen("filename1","r");
if (!fp){
printf ("Filename filename1 is not existing\n");
} else {
printf ("Filename filename1 is existing\n");
}
}
Change filename1 with full path as like "/tmp/test/filenam1" also in fopen().
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-07-2005 06:49 PM
тАО07-07-2005 06:49 PM
Re: Program in C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-08-2005 07:05 PM
тАО07-08-2005 07:05 PM
Re: Program in C
I used same routine of Muthukumar with fopen function. It works with any c and any platform.
Antonio Vigliotti.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2005 10:50 AM
тАО07-09-2005 10:50 AM
Re: Program in C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2005 12:59 PM
тАО07-09-2005 12:59 PM
Re: Program in C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2005 06:27 PM
тАО07-09-2005 06:27 PM
Re: Program in C
thank you for stat information. I read the help on stat function. I think I'll use that next time.
Antonio Vigliotti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2005 01:18 AM
тАО07-12-2005 01:18 AM
Re: Program in C
- Tags:
- access